From da251b757d3bec9b663d7b5ad4d43929f2575a4f Mon Sep 17 00:00:00 2001 From: Antoine Boonen Date: Tue, 19 Sep 2023 10:32:33 +0200 Subject: [PATCH] [FIX] account: Fix tests failing due to tax restriction. Problem --------- The tax restriction after usage creates issues in the chart template tests. Indeed, some of those test would re-create the repartition lines that were created by default after the tax is used which is not permitted anymore. Objective --------- Adapt the tests to not recreate repartition lines. Solution --------- Remove the Command create that would recreate the lines. Also, one test made use of line tags which are not present by default anymore. This test now manually sets the tag to teh line without re-creating it. task-3450002 closes odoo/odoo#130403 Signed-off-by: Quentin De Paoli --- addons/account/tests/test_chart_template.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/addons/account/tests/test_chart_template.py b/addons/account/tests/test_chart_template.py index 50984685cb2..039f479ba51 100644 --- a/addons/account/tests/test_chart_template.py +++ b/addons/account/tests/test_chart_template.py @@ -47,7 +47,7 @@ def test_get_data(self, template_code): } }, 'account.tax': { - xmlid: _tax_vals(name, amount, 'account_tax_tag_1') + xmlid: _tax_vals(name, amount) for name, xmlid, amount in [ ('Tax 1', 'test_tax_1_template', 15), ('Tax 2', 'test_tax_2_template', 0), @@ -98,8 +98,7 @@ def test_get_data(self, template_code): } } -def _tax_vals(name, amount, tax_tag_id=None, children_tax_xmlids=None, active=True): - tag_command = [Command.set([tax_tag_id])] if tax_tag_id else None +def _tax_vals(name, amount, children_tax_xmlids=None, active=True): tax_vals = { 'name': name, 'amount': amount, @@ -109,13 +108,6 @@ def _tax_vals(name, amount, tax_tag_id=None, children_tax_xmlids=None, active=Tr } if children_tax_xmlids: tax_vals.update({'children_tax_ids': [Command.set(children_tax_xmlids)]}) - else: - tax_vals.update({'repartition_line_ids': [ - Command.create({'document_type': 'invoice', 'factor_percent': 100, 'repartition_type': 'base', 'tag_ids': tag_command}), - Command.create({'document_type': 'invoice', 'factor_percent': 100, 'repartition_type': 'tax'}), - Command.create({'document_type': 'refund', 'factor_percent': 100, 'repartition_type': 'base'}), - Command.create({'document_type': 'refund', 'factor_percent': 100, 'repartition_type': 'tax'}), - ]}) return tax_vals @@ -260,6 +252,9 @@ class TestChartTemplate(TransactionCase): data['account.account.tag']['account_tax_tag_1']['name'] += ' [DUP]' return data + tax_existing = self.env['account.tax'].search([('company_id', '=', self.company_1.id), ('name', '=', 'Tax 1')]) + tag_existing = self.env['account.account.tag'].search([('name', '=', 'tax_tag_name_1')]) + tax_existing.invoice_repartition_line_ids.tag_ids = tag_existing with patch.object(AccountChartTemplate, '_get_chart_template_data', side_effect=local_get_data, autospec=True): self.env['account.chart.template'].try_loading('test', company=self.company_1, install_demo=False)