[FIX] l10n_*: translate COA on load without install
When a COA is installed being loaded for current company, the translations of taxes, account name, ... (in l10n_be, l10n_ca, l10n_ch, l10n_sa) are copied from the templates to the accounting records. This is done in `post_init_hook` which is correct since then translations are available to be copied. But when an accounting localization is already installed and we set it to a company, the translations are not copied. eg. install l10n_be for company1: accounts name are translated in french and dutch, set company2 to belgian accounting: only original language is available. With this changeset, the translation copy is also performed when an accounting localization is loaded for a company after it has been installed. note: if we install language for first times after setting accounting localizations, chart of account are translated in that language. opw-2047013 closes #35985 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
@@ -1,8 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
from . import models
|
||||
|
||||
def _post_init_hook(cr, registry):
|
||||
_preserve_tag_on_taxes(cr, registry)
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
env.ref('l10n_lu.lu_2011_chart_1').process_coa_translations()
|
||||
|
||||
def _preserve_tag_on_taxes(cr, registry):
|
||||
from odoo.addons.account.models.chart_template import preserve_existing_tags_on_taxes
|
||||
preserve_existing_tags_on_taxes(cr, registry, 'l10n_lu')
|
||||
|
||||
@@ -43,5 +43,5 @@ Notes:
|
||||
'data/account.chart.template.csv',
|
||||
'data/account_chart_template_data.xml',
|
||||
],
|
||||
'post_init_hook': '_preserve_tag_on_taxes',
|
||||
'post_init_hook': '_post_init_hook',
|
||||
}
|
||||
|
||||
@@ -12,6 +12,19 @@ _logger = logging.getLogger(__name__)
|
||||
class AccountChartTemplate(models.Model):
|
||||
_inherit = 'account.chart.template'
|
||||
|
||||
def load_for_current_company(self, sale_tax_rate, purchase_tax_rate):
|
||||
res = super(AccountChartTemplate, self).load_for_current_company(sale_tax_rate, purchase_tax_rate)
|
||||
# Copy chart of account translations when loading chart of account
|
||||
for chart_template in self.filtered('spoken_languages'):
|
||||
external_id = self.env['ir.model.data'].search([
|
||||
('model', '=', 'account.chart.template'),
|
||||
('res_id', '=', chart_template.id),
|
||||
], order='id', limit=1)
|
||||
module = external_id and self.env.ref('base.module_' + external_id.module)
|
||||
if module and module.state == 'installed':
|
||||
chart_template.process_coa_translations()
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def process_translations(self, langs, in_field, in_ids, out_ids):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user