From ad2d34cf33f8c7ef0e8a04642ccc8f3dffe727b9 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Thu, 7 Sep 2017 22:30:04 -0500 Subject: [PATCH] [FIX] account: ensure chart template translation in company's lang Before this commit, in the event that the admin user has set the language to english, but the COA's target company had a different language, the admin user's language had been taken instead of the copany's one for the translation of journals and other coa intialization stuff. This is wrong as the CoA is more connected to the company, than to the user, which could be a functional support user that just happens to prefer the english version over the local one. Now, we ensure in two neuralgic places, that the company's language is passed to the context and therefore picked up by the translation's GetTextAlias. Signed-off-by: David Arnold --- addons/account/models/chart_template.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index d205afd8e24d9..ffae12f070c03 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -283,7 +283,8 @@ def _install_template(self, company, code_digits=None, transfer_account_id=None, tmp1, tmp2 = self.parent_id._install_template(company, code_digits=code_digits, transfer_account_id=transfer_account_id, acc_ref=acc_ref, taxes_ref=taxes_ref) acc_ref.update(tmp1) taxes_ref.update(tmp2) - tmp1, tmp2 = self._load_template(company, code_digits=code_digits, transfer_account_id=transfer_account_id, account_ref=acc_ref, taxes_ref=taxes_ref) + # Ensure, even if individually, that everything is translated according to the company's language. + tmp1, tmp2 = self.with_context(lang=company.partner_id.lang)._load_template(company, code_digits=code_digits, transfer_account_id=transfer_account_id, account_ref=acc_ref, taxes_ref=taxes_ref) acc_ref.update(tmp1) taxes_ref.update(tmp2) return acc_ref, taxes_ref @@ -793,6 +794,8 @@ def execute(self): all the provided information to create the accounts, the banks, the journals, the taxes, the accounting properties... accordingly for the chosen company. ''' + # Ensure everything is translated consitingly to the company's language, not the user's one. + self = self.with_context(lang=self.company_id.partner_id.lang) if len(self.env['account.account'].search([('company_id', '=', self.company_id.id)])) > 0: # We are in a case where we already have some accounts existing, meaning that user has probably # created its own accounts and does not need a coa, so skip installation of coa.