From 039206ecb37eed13aaa019000006173c2fedf1be Mon Sep 17 00:00:00 2001 From: "Claire Bretton (clbr)" <clbr@odoo.com> Date: Thu, 11 May 2023 14:05:21 +0000 Subject: [PATCH] [FIX] account,l10n_ch: taxes update fix when no template changed When no new template are created in the update of taxes migration method the execution lead to an an error in the `_process_taxes_translations` method. Fixed a similar issue in l10n_ch migration that enables the taxes afterward and could possibly cash in the same way if no taxes are created. opw-3305302 closes odoo/odoo#121184 Signed-off-by: John Laterre (jol) <jol@odoo.com> --- addons/account/models/chart_template.py | 2 ++ addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 03ef0d207644..5b0ce9392ade 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -160,6 +160,8 @@ def update_taxes_from_templates(cr, chart_template_xmlid): Those languages are the intersection of the spoken_languages of the chart_template and installed languages. """ + if not new_template_x_taxes: + return langs = chart_template._get_langs() if langs: template_ids, tax_ids = zip(*new_template_x_taxes) diff --git a/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py b/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py index 81d93b5b9af1..f79ddef3f31b 100644 --- a/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py +++ b/addons/l10n_ch/migrations/11.1/end-migrate_update_taxes.py @@ -5,6 +5,7 @@ from odoo.addons.account.models.chart_template import update_taxes_from_template def migrate(cr, version): new_template_to_tax = update_taxes_from_templates(cr, 'l10n_ch.l10nch_chart_template') - _, new_tax_ids = zip(*new_template_to_tax) - env = api.Environment(cr, SUPERUSER_ID, {}) - env['account.tax'].browse(new_tax_ids).active = True + if new_template_to_tax: + _, new_tax_ids = zip(*new_template_to_tax) + env = api.Environment(cr, SUPERUSER_ID, {}) + env['account.tax'].browse(new_tax_ids).active = True -- GitLab