From 5d4690c23f6ad79e7b6ad200bdedd7f6cb64acca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20L=C3=B3pez=20Pe=C3=B1alver?= Date: Wed, 20 Nov 2024 15:33:49 +0100 Subject: [PATCH] [16.0][FIX] account_chart_update_multilang: error when English language is not active. @moduon MT-8060 --- .../tests/test_account_chart_update_multilang.py | 14 +++++++++++++- .../wizards/wizard_chart_update.py | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/account_chart_update_multilang/tests/test_account_chart_update_multilang.py b/account_chart_update_multilang/tests/test_account_chart_update_multilang.py index 49439540093..fe84fa8df21 100644 --- a/account_chart_update_multilang/tests/test_account_chart_update_multilang.py +++ b/account_chart_update_multilang/tests/test_account_chart_update_multilang.py @@ -32,7 +32,7 @@ def test_update_taxes(self): ] ) self.assertEqual( - new_tax.with_context(lang="en_EN").description, "tax description eng" + new_tax.with_context(lang="en_US").description, "tax description eng" ) self.assertEqual(new_tax.with_context(lang="es_ES").name, "tax name es") self.assertEqual( @@ -42,3 +42,15 @@ def test_update_taxes(self): self.assertEqual( new_tax.with_context(lang="fr_FR").description, "tax description fr" ) + + def test_update_taxes_with_english_deactivate(self): + # When English is not active the chart update should work also + self.env["res.partner"].with_context(active_test=False).search([]).write( + {"lang": "es_ES"} + ) + self.env["res.users"].with_context(active_test=False).search([]).write( + {"lang": "es_ES"} + ) + lang_model = self.env["res.lang"] + lang_model.search([("code", "=", "en_US")]).write({"active": False}) + self.test_update_taxes() diff --git a/account_chart_update_multilang/wizards/wizard_chart_update.py b/account_chart_update_multilang/wizards/wizard_chart_update.py index c26ab4942c4..76a4387b7ec 100644 --- a/account_chart_update_multilang/wizards/wizard_chart_update.py +++ b/account_chart_update_multilang/wizards/wizard_chart_update.py @@ -16,7 +16,7 @@ def _other_langs(self): def _get_lang_selection_options(self): """Only can translate in base language by default.""" - en = self.env["res.lang"]._lang_get("en_US") + en = self.env.ref("base.lang_en") return [(en.code, en.name)] def _update_other_langs(self, templates):