Skip to content
Snippets Groups Projects
Commit 680ff54c authored by Mylyna Hy's avatar Mylyna Hy
Browse files

[FIX] stock_account: search journal by code


Problem: When the user installs Inventory and uninstalls it,
the Inventory Valuation journal still exists in the database.
The user is unable to re-install Inventory
if the database not in English.

Example: Client's db is in Spanish
In method "_configure_journals" ,
it searches for the Inventory Valuation journal based on the name translated in Spanish.
However, the journal "Inventory Valuation" is not translated to Spanish in the database.
Therefore, no journal would be found
and an error "Journal codes must be unique per company" will be thrown
because it will try to create another "Inventory Valuation" journal with code  'STJ'.

Solution:
Since journal codes have to be unique, it is more logical to search for an
existing journal based on its code instead of the name
since it is possible to have multiple journals with the same name but different codes.

opw-3277498

closes odoo/odoo#118982

Signed-off-by: default avatarTiffany Chang <tic@odoo.com>
parent 42ec2a08
No related branches found
No related tags found
No related merge requests found
......@@ -28,10 +28,10 @@ def _configure_journals(cr, registry):
('fields_id', '=', field.id),
('company_id', '=', company_id.id)])
# If not, check if you can find a journal that is already there with the same name, otherwise create one
# If not, check if you can find a journal that is already there with the same code, otherwise create one
if not properties:
journal_id = env['account.journal'].search([
('name', '=', _('Inventory Valuation')),
('code', '=', 'STJ'),
('company_id', '=', company_id.id),
('type', '=', 'general')], limit=1).id
if not journal_id:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment