changeset cb0a2d8c4a99 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=cb0a2d8c4a99
description:
Remove id to on_change calls that are cached
issue8234
review275131002
diffstat:
tryton/common/selection.py | 2 +-
tryton/gui/window/view_form/model/record.py | 26 +++++++++++++++++++++-----
2 files changed, 22 insertions(+), 6 deletions(-)
diffs (62 lines):
diff -r d3af4b3aa7f5 -r cb0a2d8c4a99 tryton/common/selection.py
--- a/tryton/common/selection.py Mon Apr 08 10:10:40 2019 +0200
+++ b/tryton/common/selection.py Mon Apr 08 10:14:39 2019 +0200
@@ -52,7 +52,7 @@
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 -r d3af4b3aa7f5 -r cb0a2d8c4a99 tryton/gui/window/view_form/model/record.py
--- a/tryton/gui/window/view_form/model/record.py Mon Apr 08 10:10:40
2019 +0200
+++ b/tryton/gui/window/view_form/model/record.py Mon Apr 08 10:14:39
2019 +0200
@@ -513,7 +513,6 @@
scope = scope[i]
else:
res[arg] = scope
- res['id'] = self.id
return res
def on_change(self, fieldnames):
@@ -526,8 +525,16 @@
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 @@
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)