changeset 97b575fc91e5 in modules/party:default
details: https://hg.tryton.org/modules/party?cmd=changeset&node=97b575fc91e5
description:
Support replacing party on reference field
issue10611
review362271002
diffstat:
CHANGELOG | 1 +
party.py | 11 +++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diffs (38 lines):
diff -r e75508d267ca -r 97b575fc91e5 CHANGELOG
--- a/CHANGELOG Sun Oct 10 22:18:57 2021 +0200
+++ b/CHANGELOG Tue Oct 12 10:07:14 2021 +0200
@@ -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 -r e75508d267ca -r 97b575fc91e5 party.py
--- a/party.py Sun Oct 10 22:18:57 2021 +0200
+++ b/party.py Tue Oct 12 10:07:14 2021 +0200
@@ -823,9 +823,16 @@
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 @@
cursor.execute(*table.update(
[column],
- [destination.id],
+ [destination_value],
where=where,
returning=returning))