[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) <flg@odoo.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user