From b265184593e4ecd5d1be5c22e38006b983007f31 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 24 Jul 2024 16:24:44 +0200 Subject: [PATCH] [FIX] l10n_nl_tax_statement: don't break when writing list of ids on x2many --- l10n_nl_tax_statement/models/account_move_line.py | 4 +++- l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/l10n_nl_tax_statement/models/account_move_line.py b/l10n_nl_tax_statement/models/account_move_line.py index 3de356bc7..5695c1d7e 100644 --- a/l10n_nl_tax_statement/models/account_move_line.py +++ b/l10n_nl_tax_statement/models/account_move_line.py @@ -37,7 +37,9 @@ def check_field_is_equal(self, changed_protected_field, values): old_value = self[changed_protected_field] new_value = values[changed_protected_field] if field.type in ["many2many", "one2many"]: - # if field is X2M , the only acceptable value is + if all(isinstance(_id, int) for _id in new_value): + return new_value == old_value.ids + # if field is X2M , the only other acceptable value is # [[6,0,self[changed_protected_field].ids]] # wich is what the web client posts in case there is a editable X2M in form # that is unchanged. diff --git a/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py b/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py index 16fdec7ad..cce508051 100644 --- a/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py +++ b/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py @@ -581,3 +581,8 @@ def test_20_multicompany(self): company_ids_full_list = statement_parent._get_company_ids_full_list() self.assertEqual(len(company_ids_full_list), 3) + + def test_21_write_id_list(self): + self._create_test_invoice() + self.invoice_1.line_ids.write({"tax_tag_ids": self.tag_1.ids}) + self.assertEqual(self.invoice_1.mapped("line_ids.tax_tag_ids"), self.tag_1)