From 355fbc8ef52fcc9f4e1a47c1af69a202ae66c5b2 Mon Sep 17 00:00:00 2001 From: David Blanco Bautista Date: Fri, 8 Oct 2021 19:34:33 +0200 Subject: [PATCH] Make identifiers deactivatable and replace it issue10567 review346941002 --- CHANGELOG | 2 ++ party.py | 7 ++++++- tests/scenario_party_replace.rst | 14 ++++++++++++++ view/identifier_form.xml | 8 ++++++-- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0ed09040b7..d22d7c9b87 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Make identifiers deactivatable +* Replace party on identifier when replacing parties * Add au_abn and au_acn as tax identifiers * Add at, ua and vn party identifiers diff --git a/party.py b/party.py index d28926d1ec..fc563d3215 100644 --- a/party.py +++ b/party.py @@ -564,7 +564,7 @@ TAX_IDENTIFIER_TYPES = [ ] -class Identifier(sequence_ordered(), ModelSQL, ModelView): +class Identifier(sequence_ordered(), DeactivableMixin, ModelSQL, ModelView): 'Party Identifier' __name__ = 'party.identifier' _rec_name = 'code' @@ -754,6 +754,7 @@ class Replace(Wizard): pool = Pool() Address = pool.get('party.address') ContactMechanism = pool.get('party.contact_mechanism') + Identifier = pool.get('party.identifier') transaction = Transaction() self.check_similarity() @@ -766,6 +767,9 @@ class Replace(Wizard): ContactMechanism.write(list(source.contact_mechanisms), { 'active': False, }) + Identifier.write(list(source.identifiers), { + 'active': False, + }) source.replaced_by = destination source.active = False source.save() @@ -801,6 +805,7 @@ class Replace(Wizard): return [ ('party.address', 'party'), ('party.contact_mechanism', 'party'), + ('party.identifier', 'party'), ] diff --git a/tests/scenario_party_replace.rst b/tests/scenario_party_replace.rst index 380106b99c..18ef150201 100644 --- a/tests/scenario_party_replace.rst +++ b/tests/scenario_party_replace.rst @@ -15,14 +15,22 @@ Create a party:: >>> Party = Model.get('party.party') >>> party1 = Party(name='Pam') + >>> identifier1 = party1.identifiers.new() + >>> identifier1.type = 'eu_vat' + >>> identifier1.code = 'BE0897290877' >>> party1.save() >>> address1, = party1.addresses + >>> identifier1, = party1.identifiers Create a second party similar party:: >>> party2 = Party(name='Pam') + >>> identifier2 = party2.identifiers.new() + >>> identifier2.type = 'eu_vat' + >>> identifier2.code = 'BE0897290877' >>> party2.save() >>> address2, = party2.addresses + >>> identifier2, = party2.identifiers Replace the second by the first party:: @@ -36,6 +44,12 @@ Replace the second by the first party:: >>> bool(party2.active) False + >>> identifier2.reload() + >>> identifier2.party == party1 + True + >>> bool(identifier2.active) + False + >>> address2.reload() >>> address2.party == party1 True diff --git a/view/identifier_form.xml b/view/identifier_form.xml index 690de9dffc..0a58dfdad7 100644 --- a/view/identifier_form.xml +++ b/view/identifier_form.xml @@ -4,8 +4,12 @@ this repository contains the full copyright notices and license terms. -->