From cab2cddf72abff6af1e0e312e2ba6ae9645d61ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 15 Dec 2023 19:10:38 +0100 Subject: [PATCH] Always include changed field when calling on_change_with Since d142b33fa3ab the on_change_with relies on _changed_value. So in order to correctly detect if a xxx2Many field has some record removed, we need to have the value of the client. Closes #12837 (grafted from ae091a6bacbcaba5d327c6573b3859ab0d59e070) --HG-- branch : 7.0 --- proteus/proteus/__init__.py | 4 ++-- sao/src/model.js | 6 ++++-- tryton/tryton/gui/window/view_form/model/record.py | 6 ++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/proteus/proteus/__init__.py b/proteus/proteus/__init__.py index 63a91c5f9b..392e679b4e 100644 --- a/proteus/proteus/__init__.py +++ b/proteus/proteus/__init__.py @@ -1169,7 +1169,7 @@ class Model(object): later.add(field) continue to_change.add(field) - values.update(self._on_change_args(on_change_with)) + values.update(self._on_change_args(on_change_with + [field])) if to_change: context = self._context changes = getattr(self._proxy, 'on_change_with')(values, @@ -1179,7 +1179,7 @@ class Model(object): values = {} for field in later: on_change_with = self._fields[field]['on_change_with'] - values.update(self._on_change_args(on_change_with)) + values.update(self._on_change_args(on_change_with + [field])) context = self._context changes = getattr(self._proxy, 'on_change_with')( values, list(later), context) diff --git a/sao/src/model.js b/sao/src/model.js index c8e4b8ecef..2008f3b647 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -1128,7 +1128,8 @@ } fieldnames[fieldname] = true; values = jQuery.extend(values, - this._get_on_change_args(on_change_with)); + this._get_on_change_args( + on_change_with.concat([fieldname]))); if ((this.model.fields[fieldname] instanceof Sao.field.Many2One) || (this.model.fields[fieldname] instanceof @@ -1167,7 +1168,8 @@ .description.on_change_with; values = jQuery.extend( values, - this._get_on_change_args(on_change_with)); + this._get_on_change_args( + on_change_with.concat([fieldname]))); } fieldnames = Object.keys(later); try { diff --git a/tryton/tryton/gui/window/view_form/model/record.py b/tryton/tryton/gui/window/view_form/model/record.py index 670abb22cf..826f13dbb0 100644 --- a/tryton/tryton/gui/window/view_form/model/record.py +++ b/tryton/tryton/gui/window/view_form/model/record.py @@ -622,7 +622,8 @@ class Record: later.add(fieldname) continue fieldnames.add(fieldname) - values.update(self._get_on_change_args(on_change_with)) + values.update( + self._get_on_change_args(on_change_with + [fieldname])) if isinstance(self.group.fields[fieldname], (fields.M2OField, fields.ReferenceField)): self.value.pop(fieldname + '.', None) @@ -647,7 +648,8 @@ class Record: for fieldname in later: on_change_with = self.group.fields[fieldname].attrs.get( 'on_change_with') - values.update(self._get_on_change_args(on_change_with)) + values.update( + self._get_on_change_args(on_change_with + [fieldname])) try: if len(later) == 1 or 'id' not in values: changed = {}