[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) <vin@odoo.com>
Signed-off-by: Ricardo Gomes Rodrigues (rigr) <rigr@odoo.com>
This commit is contained in:
Ricardo Gomes Rodrigues (rigr)
2022-12-08 14:44:20 +01:00
parent 348265db3d
commit 6db6eb60e6
@@ -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