From 4f2982f403db90b720c325c40fd7a934dbeafc11 Mon Sep 17 00:00:00 2001 From: Antoine Boonen Date: Thu, 25 Jan 2024 16:54:35 +0100 Subject: [PATCH] [REV] account: Fix test in account taxes Revert of commit da251b757d3bec9b663d7b5ad4d43929f2575a4f Problem --------- In said commit, tests were failing due to 1. the new restrictions on tax 2. default creation of repartition lines. However, updating the way chart_template._get_chart_template_data is patched in those tests was not the way to go. Because of that, some fixes due to migration error to 17.0 failed - PR #149733. closes odoo/odoo#151189 Signed-off-by: Brice Bartoletti (bib) --- addons/account/tests/test_chart_template.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/addons/account/tests/test_chart_template.py b/addons/account/tests/test_chart_template.py index 6f6e0ddf62d..7f537a381c5 100644 --- a/addons/account/tests/test_chart_template.py +++ b/addons/account/tests/test_chart_template.py @@ -48,7 +48,7 @@ def test_get_data(self, template_code): } }, 'account.tax': { - xmlid: _tax_vals(name, amount) + xmlid: _tax_vals(name, amount, 'account.account_tax_tag_1') for name, xmlid, amount in [ ('Tax 1', 'test_tax_1_template', 15), ('Tax 2', 'test_tax_2_template', 0), @@ -99,7 +99,8 @@ def test_get_data(self, template_code): } } -def _tax_vals(name, amount, children_tax_xmlids=None, active=True): +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 tax_vals = { 'name': name, 'amount': amount, @@ -109,6 +110,13 @@ def _tax_vals(name, amount, children_tax_xmlids=None, active=True): } 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 @@ -253,9 +261,6 @@ class TestChartTemplate(TransactionCase): data['account.account.tag']['account.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)