From 5c7326eea3056a96c6a1ff65889673ee11b6c70c Mon Sep 17 00:00:00 2001 From: "Claire Bretton (clbr)" Date: Tue, 16 May 2023 12:09:50 +0000 Subject: [PATCH] [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) Signed-off-by: Claire Bretton --- addons/account/models/chart_template.py | 2 ++ addons/l10n_ch/migrations/11.1/post-migrate_update_taxes.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index e3165b07cea..0ec7c84ae97 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -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] diff --git a/addons/l10n_ch/migrations/11.1/post-migrate_update_taxes.py b/addons/l10n_ch/migrations/11.1/post-migrate_update_taxes.py index 6b420315510..fb8c8112c91 100644 --- a/addons/l10n_ch/migrations/11.1/post-migrate_update_taxes.py +++ b/addons/l10n_ch/migrations/11.1/post-migrate_update_taxes.py @@ -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)