From bfa27f512c7d38678ae6392c678788ee4fb9a992 Mon Sep 17 00:00:00 2001 From: "Gauthier Wala (gawa)" Date: Fri, 1 Mar 2024 09:11:30 +0100 Subject: [PATCH] [FIX] account: taxes with amount_type 'group' are not well reloaded To reproduce: - Install l10n_it - Go in settings - Fiscal Localization => reload - Go to the taxes => You will find taxes with [old] prefix The issue comes that we want to consider that a tax has changed if it has different repartition lines. We don't consider taxes that are defined without repartition lines. The template will have no lines, but the compute on actual taxes will generate default ones. It then considers that the tax has changed. task-3777629 closes odoo/odoo#156974 X-original-commit: 55c09d3fab70d241174c44a9f3d123a01211730e Signed-off-by: Florian Gilbert (flg) --- addons/account/models/chart_template.py | 6 +++++- addons/account/tests/test_chart_template.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index dd275d218d2..f3eeb4bae50 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -265,7 +265,11 @@ class AccountChartTemplate(models.AbstractModel): return ( tax.amount_type != template.get('amount_type', 'percent') or tax.amount != template.get('amount', 0) - or len(tax.repartition_line_ids) != len(template.get('repartition_line_ids', [])) + or ( + len(tax.repartition_line_ids) != len(template.get('repartition_line_ids', [])) + # Taxes that don't have repartition lines in their templates get theirs created by default + and len(template.get('repartition_line_ids', [])) != 0 + ) ) obsolete_xmlid = set() diff --git a/addons/account/tests/test_chart_template.py b/addons/account/tests/test_chart_template.py index 033213b7770..8b3442a6934 100644 --- a/addons/account/tests/test_chart_template.py +++ b/addons/account/tests/test_chart_template.py @@ -444,6 +444,12 @@ class TestChartTemplate(TransactionCase): self.assertEqual(len(children_taxes), 2, "Two children should have been created.") self.assertEqual(parent_tax.children_tax_ids.ids, children_taxes.ids, "The parent and its children taxes should be linked together.") + with patch.object(AccountChartTemplate, '_get_chart_template_data', side_effect=local_get_data, autospec=True): + # We don't change anything + self.env['account.chart.template'].try_loading('test', company=self.company_1, install_demo=False) + + self.assertEqual(parent_tax.name, 'Tax with children', "The parent tax created before should not have changed") + def test_update_taxes_children_tax_ids_inactive(self): """ Ensure tax templates are correctly generated when updating taxes with children taxes, even if templates are inactive.