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.