From b72a6f0e7d4b02e1230b2b39aec8bd50dd66b0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 12 Dec 2024 17:42:32 +0100 Subject: [PATCH] Call on_change_notify for fields update by on_change Closes #13753 --- sao/src/model.js | 11 ++++++++--- tryton/tryton/gui/window/view_form/model/record.py | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sao/src/model.js b/sao/src/model.js index e8516192a7..27f3d51eff 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -1096,6 +1096,7 @@ this._get_on_change_args(on_change)); } } + let modified = new Set(fieldnames); if (!jQuery.isEmptyObject(values)) { values.id = this.id; var changes; @@ -1116,13 +1117,17 @@ } catch (e) { return; } - changes.forEach(this.set_on_change, this); + changes.forEach((values) => { + this.set_on_change(values); + for (let fieldname in values) { + modified.add(fieldname); + } + }); } var notification_fields = Sao.common.MODELNOTIFICATION.get( this.model.name); - var notification_fields_set = new Set(notification_fields); - if (fieldnames.some(field => notification_fields_set.has(field))) { + if (modified.intersection(new Set(notification_fields)).size) { values = this._get_on_change_args(notification_fields); this.model.execute( 'on_change_notify', [values], this.get_context()) diff --git a/tryton/tryton/gui/window/view_form/model/record.py b/tryton/tryton/gui/window/view_form/model/record.py index 896f59479c..1e18e690fc 100644 --- a/tryton/tryton/gui/window/view_form/model/record.py +++ b/tryton/tryton/gui/window/view_form/model/record.py @@ -606,6 +606,7 @@ class Record: continue values.update(self._get_on_change_args(on_change)) + modified = set(fieldnames) if values: values['id'] = self.id try: @@ -625,9 +626,10 @@ class Record: else: for change in changes: self.set_on_change(change) + modified.update(change) notification_fields = common.MODELNOTIFICATION.get(self.model_name) - if set(fieldnames) & set(notification_fields): + if modified & set(notification_fields): values = self._get_on_change_args(notification_fields) try: notifications = RPCExecute(