From 5bb896d2fdd69f8d940352f8d5833fe88a443ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Cifuentes?= Date: Fri, 19 Jul 2024 16:02:43 +0200 Subject: [PATCH] [16.0][FIX] account_chart_update: prevent malformed xmlid during update --- .../tests/test_account_chart_update.py | 10 ++++++++++ account_chart_update/wizard/wizard_chart_update.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/account_chart_update/tests/test_account_chart_update.py b/account_chart_update/tests/test_account_chart_update.py index fa729055e..53ac4376a 100644 --- a/account_chart_update/tests/test_account_chart_update.py +++ b/account_chart_update/tests/test_account_chart_update.py @@ -543,6 +543,14 @@ class TestAccountChartUpdate(common.TransactionCase): self.assertEqual(self.tax.description, self.tax_template.description) self.assertEqual(self.account.code, self.account_template.code) self.assertEqual(self.fp.name, self.fp_template.name) + fp_id = wizard.find_fp_by_templates(self.fp_template) + fp_rec = self.env["account.fiscal.position"].browse(fp_id) + expected_xmlid = "{}.{}_{}".format( + "account_chart_update", + wizard.company_id.id, + "account_fiscal_position_template-{}".format(self.fp_template.id), + ) + self.assertEqual(fp_rec.get_external_id().get(fp_id), expected_xmlid) wizard.unlink() # Test match by another field, there is no match by XML-ID @@ -613,6 +621,7 @@ class TestAccountChartUpdate(common.TransactionCase): self.assertTrue(list(self.tax.get_external_id().values())[0]) self.assertTrue(list(self.account.get_external_id().values())[0]) self.assertTrue(list(self.fp.get_external_id().values())[0]) + self.assertEqual(fp_rec.get_external_id().get(fp_id), expected_xmlid) wizard.unlink() # Test 2 recreate XML-ID @@ -642,4 +651,5 @@ class TestAccountChartUpdate(common.TransactionCase): self.assertTrue(list(self.tax.get_external_id().values())[0]) self.assertTrue(list(self.account.get_external_id().values())[0]) self.assertTrue(list(self.fp.get_external_id().values())[0]) + self.assertEqual(fp_rec.get_external_id().get(fp_id), expected_xmlid) wizard.unlink() diff --git a/account_chart_update/wizard/wizard_chart_update.py b/account_chart_update/wizard/wizard_chart_update.py index c855c6045..e4177fddd 100644 --- a/account_chart_update/wizard/wizard_chart_update.py +++ b/account_chart_update/wizard/wizard_chart_update.py @@ -1100,14 +1100,14 @@ class WizardUpdateChartsAccounts(models.TransientModel): ir_model_data.search( [("model", "=", real_obj._name), ("res_id", "=", real_obj.id)] ).unlink() - template_xmlid.copy( + new_rec = template_xmlid.copy( { "model": real_obj._name, "res_id": real_obj.id, - "name": new_xml_id, "noupdate": True, } ) + new_rec.name = new_xml_id def _update_taxes(self): """Process taxes to create/update/deactivate."""