@@ -1176,13 +1176,15 @@ class Model(object):
|
||||
changes = getattr(self._proxy, 'on_change_with')(values,
|
||||
list(to_change), context)
|
||||
self._set_on_change(changes)
|
||||
for field in later:
|
||||
on_change_with = self._fields[field]['on_change_with']
|
||||
values = self._on_change_args(on_change_with)
|
||||
if later:
|
||||
values = {}
|
||||
for field in later:
|
||||
on_change_with = self._fields[field]['on_change_with']
|
||||
values.update(self._on_change_args(on_change_with))
|
||||
context = self._context
|
||||
result = getattr(self._proxy, 'on_change_with_%s' % field)(values,
|
||||
context)
|
||||
self._on_change_set(field, result)
|
||||
changes = getattr(self._proxy, 'on_change_with')(
|
||||
values, list(later), context)
|
||||
self._set_on_change(changes)
|
||||
|
||||
if self._parent:
|
||||
self._parent._changed.add(self._parent_field_name)
|
||||
|
||||
+22
-8
@@ -1144,18 +1144,32 @@
|
||||
}
|
||||
this.set_on_change(result);
|
||||
}
|
||||
for (fieldname in later) {
|
||||
on_change_with = this.model.fields[fieldname]
|
||||
.description.on_change_with;
|
||||
values = this._get_on_change_args(on_change_with);
|
||||
if (!jQuery.isEmptyObject(later)) {
|
||||
values = {};
|
||||
for (fieldname in later) {
|
||||
on_change_with = this.model.fields[fieldname]
|
||||
.description.on_change_with;
|
||||
values = jQuery.extend(
|
||||
values,
|
||||
this._get_on_change_args(on_change_with));
|
||||
}
|
||||
fieldnames = Object.keys(later);
|
||||
try {
|
||||
result = this.model.execute(
|
||||
'on_change_with_' + fieldname,
|
||||
[values], this.get_context(), false);
|
||||
if (fieldnames.length == 1) {
|
||||
fieldname = fieldnames[0];
|
||||
result = {};
|
||||
result[fieldname] = this.model.execute(
|
||||
'on_change_with_' + fieldname,
|
||||
[values], this.get_context(), false);
|
||||
} else {
|
||||
result = this.model.execute(
|
||||
'on_change_with',
|
||||
[values, fieldnames], this.get_context(), false);
|
||||
}
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
this.load(fieldname, false).set_on_change(this, result);
|
||||
this.set_on_change(result);
|
||||
}
|
||||
},
|
||||
set_on_change: function(values) {
|
||||
|
||||
@@ -632,18 +632,27 @@ class Record:
|
||||
except RPCException:
|
||||
return
|
||||
self.set_on_change(result)
|
||||
for fieldname in later:
|
||||
on_change_with = self.group.fields[fieldname].attrs.get(
|
||||
'on_change_with')
|
||||
values = self._get_on_change_args(on_change_with)
|
||||
if later:
|
||||
values = {}
|
||||
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))
|
||||
try:
|
||||
result = RPCExecute('model', self.model_name,
|
||||
'on_change_with_' + fieldname, values,
|
||||
context=self.get_context())
|
||||
if len(later) == 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(later), context=self.get_context())
|
||||
except RPCException:
|
||||
return
|
||||
# Load fieldname before setting value
|
||||
self[fieldname].set_on_change(self, result)
|
||||
self.set_on_change(result)
|
||||
|
||||
def autocomplete_with(self, field_name):
|
||||
for fieldname, fieldinfo in self.group.fields.items():
|
||||
|
||||
@@ -773,6 +773,7 @@ class ModelView(Model):
|
||||
field = self._fields[fieldname]
|
||||
method_name = 'on_change_with_%s' % fieldname
|
||||
value = getattr(self, method_name)()
|
||||
setattr(self, fieldname, value)
|
||||
if field._type in {'many2one', 'one2one', 'reference'}:
|
||||
if isinstance(value, ModelStorage):
|
||||
if value.id and value.id >= 0:
|
||||
|
||||
Reference in New Issue
Block a user