From 6db6eb60e6865eb1dbc5bb11692e4869cf6ef5bb Mon Sep 17 00:00:00 2001 From: "Ricardo Gomes Rodrigues (rigr)" Date: Wed, 7 Dec 2022 09:13:27 +0000 Subject: [PATCH] [FIX] l10n_multilang: CoA not translated if the language is installed after the CoA Currently there is a bug where the Chart of Accounts is not translated if the language is installed after the CoA. Steps to reproduce: 1. Create a CA company (where both French and English are used) 2. Set the CA Chart of Accounts 3. Go to the general settings 4. Add the French language and switch to it 5. Go back to the CoA 6. The CoA is not translated This is because the variable `installed` is wrongfully placed in the code. In the current flow, we install the new language, then we check the installed language, therefore the new language is marked as an already installed language. Therfore the `to_install` variable will always be empty. This commit fixes this by first storing the already installed languages, then installing the new one, and then compute the ones to install making sure that the newly installed one will be used afterwards to translate the Chart of Accounts. task-id 3091315 closes odoo/odoo#107500 X-original-commit: a3c3c3ccfc8e769ce39dbf38263f92e449b44abb Signed-off-by: Nicolas Viseur (vin) Signed-off-by: Ricardo Gomes Rodrigues (rigr) --- addons/l10n_multilang/models/l10n_multilang.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/l10n_multilang/models/l10n_multilang.py b/addons/l10n_multilang/models/l10n_multilang.py index dc133f5a509..a6aa29ff8f6 100644 --- a/addons/l10n_multilang/models/l10n_multilang.py +++ b/addons/l10n_multilang/models/l10n_multilang.py @@ -134,10 +134,9 @@ class BaseLanguageInstall(models.TransientModel): def lang_install(self): self.ensure_one() - res = super(BaseLanguageInstall, self).lang_install() - lang_codes = set(self.lang_ids.mapped('code')) installed = {code for code, __ in self.env['res.lang'].get_installed()} - to_install = lang_codes - installed + res = super(BaseLanguageInstall, self).lang_install() + to_install = set(self.lang_ids.mapped('code')) - installed if not to_install: # update of translations instead of new installation # skip to avoid duplicating the translations