Skip to content

Commit

Permalink
[FIX] account: ensure chart template translation in company's lang
Browse files Browse the repository at this point in the history
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 <dar@xoe.solutions>
  • Loading branch information
David Arnold authored and qdp-odoo committed Jan 3, 2018
1 parent 36e7847 commit ad2d34c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion addons/account/models/chart_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit ad2d34c

Please sign in to comment.