From 5c6d71f72c615a72c1f2ecda445bd2e62178a34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 8 Apr 2019 10:14:39 +0200 Subject: [PATCH] Remove id to on_change calls that are cached issue8234 review275131002 --- tryton/common/selection.py | 2 +- tryton/gui/window/view_form/model/record.py | 26 +++++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tryton/common/selection.py b/tryton/common/selection.py index 6eff80c1c1..495005010d 100644 --- a/tryton/common/selection.py +++ b/tryton/common/selection.py @@ -52,7 +52,7 @@ class SelectionMixin(object): if 'relation' not in self.attrs: change_with = self.attrs.get('selection_change_with') or [] value = record._get_on_change_args(change_with) - del value['id'] + value.pop('id', None) self.init_selection(value) self.filter_selection(domain, record, field) else: diff --git a/tryton/gui/window/view_form/model/record.py b/tryton/gui/window/view_form/model/record.py index 064b53b010..b3ffc333c3 100644 --- a/tryton/gui/window/view_form/model/record.py +++ b/tryton/gui/window/view_form/model/record.py @@ -513,7 +513,6 @@ class Record(SignalEvent): scope = scope[i] else: res[arg] = scope - res['id'] = self.id return res def on_change(self, fieldnames): @@ -526,8 +525,16 @@ class Record(SignalEvent): if values: try: - changes = RPCExecute('model', self.model_name, 'on_change', - values, fieldnames, context=self.get_context()) + if len(fieldnames) == 1: + fieldname, = fieldnames + changes = [] + changes.append(RPCExecute( + 'model', self.model_name, 'on_change_' + fieldname, + values, context=self.get_context())) + else: + changes = RPCExecute( + 'model', self.model_name, 'on_change', + values, fieldnames, context=self.get_context()) except RPCException: return for change in changes: @@ -555,8 +562,17 @@ class Record(SignalEvent): self.value.pop(fieldname + '.', None) if fieldnames: try: - result = RPCExecute('model', self.model_name, 'on_change_with', - values, list(fieldnames), context=self.get_context()) + if len(fieldnames) == 1: + fieldname, = fieldnames + result = {} + result[fieldname] = RPCExecute( + 'model', self.model_name, + 'on_change_with_' + fieldname, + values, context=self.get_context()) + else: + result = RPCExecute( + 'model', self.model_name, 'on_change_with', + values, list(fieldnames), context=self.get_context()) except RPCException: return self.set_on_change(result)