[FIX] account, l10n_ch: enable new taxes after module update

Swiss taxes retrieved by module update (and the update of taxes it triggers)
need to be active, even if the template data was set to inactive.

closes odoo/odoo#121580

X-original-commit: 04f0be5
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Claire Bretton <clbr@odoo.com>
This commit is contained in:
Claire Bretton (clbr)
2023-05-17 10:34:07 +02:00
parent b43ba1bb1f
commit 5c7326eea3
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -276,6 +276,8 @@ class AccountChartTemplate(models.AbstractModel):
elif model_name == 'account.tax':
# Only update the tags of existing taxes
if xmlid not in xmlid2tax or tax_template_changed(xmlid2tax[xmlid], values):
if self._context.get('force_new_tax_active'):
values['active'] = True
if xmlid in xmlid2tax:
obsolete_xmlid.add(xmlid)
oldtax = xmlid2tax[xmlid]
@@ -5,4 +5,4 @@ from odoo import api, SUPERUSER_ID
def migrate(cr, version):
env = api.Environment(cr, SUPERUSER_ID, {})
for company in env['res.company'].search([('chart_template', '=', 'ch')]):
env['account.chart.template'].try_loading('ch', company)
env['account.chart.template'].with_context(force_new_tax_active=True).try_loading('ch', company)