From 6e30206fdb994704f576efb46be1edf3953adbe9 Mon Sep 17 00:00:00 2001 From: "Antoine Dupuis (andu)" Date: Mon, 8 May 2023 16:07:18 +0000 Subject: [PATCH] [FIX] account: Correctly translate terms when loading CoA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bugfix: at the moment, if the environment's language is not en_US, loading a CoA doesn't correctly load the translations: the translations for all languages are created with the en_US terms. Steps to reproduce: 1. Create a DB and install l10n_be. 2. Switch to French. 2. Create a new company based in Belgium. 3. Install the Belgian CoA on the company. Expected behaviour: The accounts should be in French. Actual behaviour: The French translation of the accounts contains the terms in English. Analysis: When the records are created by _load_records(), the language of the environment is French. As a result, all translatable terms are created with translations in en_US and in fr_FR. See https://github.com/odoo/odoo/blob/39292a02ab34ea86abd5601055901eb968006944/odoo/fields.py#L1762-L1771 Later on, when the translations are loaded by _load_translations, there already exists a name->'fr_FR', so our call to translation_importer.save(overwrite=False) doesn't want to overwrite it. See https://github.com/odoo/odoo/blob/2780c37cfdb8560ac7c725fd27f4fe272f1d3072/addons/account/models/chart_template.py#L787 As a result, we end up with the English terms in both the en_US and fr_FR translations. The fix: Set the language to en_US when calling _load_records(). closes odoo/odoo#120863 X-original-commit: 52ef69aa8423a0fd5d78af1ab018a98dba87361c Signed-off-by: William André (wan) --- addons/account/models/chart_template.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index f2ffe2f4fd4..b642e18c3f5 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -430,7 +430,7 @@ class AccountChartTemplate(models.AbstractModel): 'values': deref(record, self.env[model]), 'noupdate': True, }) - created_vals[model] = self.env[model]._load_records(create_vals) + created_vals[model] = self.with_context(lang='en_US').env[model]._load_records(create_vals) return created_vals def _post_load_data(self, template_code, company, template_data):