From e646fc31e605443c082f9c011db2839efd28a3da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 12 Oct 2021 10:07:14 +0200 Subject: [PATCH] Support replacing party on reference field issue10611 review362271002 --- CHANGELOG | 1 + party.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5f3a802883..b2d8db6175 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Support replacing party on reference field * Allow setting a single contact mechanism at party creation * Make identifiers deactivatable * Replace party on identifier when replacing parties diff --git a/party.py b/party.py index 851441a318..fd6a638144 100644 --- a/party.py +++ b/party.py @@ -823,9 +823,16 @@ class Replace(Wizard): cursor = transaction.connection.cursor() for model_name, field_name in self.fields_to_replace(): Model = pool.get(model_name) + field = getattr(Model, field_name) table = Model.__table__() column = Column(table, field_name) - where = column == source.id + if field._type == 'reference': + source_value = str(source) + destination_value = str(destination) + else: + source_value = source.id + destination_value = destination.id + where = column == source_value if transaction.database.has_returning(): returning = [table.id] @@ -836,7 +843,7 @@ class Replace(Wizard): cursor.execute(*table.update( [column], - [destination.id], + [destination_value], where=where, returning=returning))