Reviewers: ,
Please review this at http://codereview.tryton.org/249004/
Affected files:
M tryton/gui/window/view_form/model/record.py
Index: tryton/gui/window/view_form/model/record.py
===================================================================
--- a/tryton/gui/window/view_form/model/record.py
+++ b/tryton/gui/window/view_form/model/record.py
@@ -526,6 +526,9 @@
field_x2many.in_on_change = False
def on_change_with(self, field_name):
+ fieldnames = set()
+ values = {}
+ later = set()
for fieldname in self.group.fields:
on_change_with = self.group.fields[fieldname].attrs.get(
'on_change_with')
@@ -535,18 +538,35 @@
continue
if field_name == fieldname:
continue
- args = self._get_on_change_args(on_change_with)
- ctx = rpc.CONTEXT.copy()
- ctx.update(self.context_get())
+ if fieldnames & set(on_change_with):
+ later.add(fieldname)
+ continue
+ fieldnames.add(fieldname)
+ values.update(self._get_on_change_args(on_change_with))
+ ctx = rpc.CONTEXT.copy()
+ ctx.update(self.context_get())
+ if fieldnames:
+ args = ('model', self.model_name, 'on_change_with',
+ list(fieldnames), values, ctx)
+ try:
+ result = rpc.execute(*args)
+ except TrytonServerError, exception:
+ result = common.process_exception(exception, *args)
+ if not result:
+ return
+ for fieldname, value in result.items():
+ self.group.fields[fieldname].set_on_change(self, value)
+ for fieldname in later:
+ values = self._get_on_change_args(on_change_with)
args = ('model', self.model_name, 'on_change_with_' +
fieldname,
- args, ctx)
+ values, ctx)
try:
- res = rpc.execute(*args)
+ result = rpc.execute(*args)
except TrytonServerError, exception:
- res = common.process_exception(exception, *args)
- if not res:
+ result = common.process_exception(exception, *args)
+ if not result:
return
- self.group.fields[fieldname].set_on_change(self, res)
+ self.group.fields[fieldname].set_on_change(self, result)
def autocomplete_with(self, field_name):
for fieldname, fieldinfo in self.group.fields.iteritems():
--
[email protected] mailing list