[FIX] models: in onchange(), do not send a field value if it has not changed
The method onchange() executes onchange methods in cascade. Suppose onchange() is called and a field F=1 in the form. If an onchange method set F=2, that value is put in the result variable. If another onchange method set it back to F=1, the binding F=2 must be removed from the result variable. Fixes #2309
This commit is contained in:
parent
e948253b3a
commit
85533e1841
|
@ -5693,14 +5693,28 @@ class BaseModel(object):
|
||||||
|
|
||||||
# determine which fields have been modified
|
# determine which fields have been modified
|
||||||
for name, oldval in values.iteritems():
|
for name, oldval in values.iteritems():
|
||||||
newval = record[name]
|
|
||||||
field = self._fields[name]
|
field = self._fields[name]
|
||||||
if newval != oldval or \
|
newval = record[name]
|
||||||
field.type in ('one2many', 'many2many') and newval._dirty:
|
if field.type in ('one2many', 'many2many'):
|
||||||
result['value'][name] = field.convert_to_write(
|
if newval != oldval or newval._dirty:
|
||||||
newval, record._origin, subfields.get(name),
|
# put new value in result
|
||||||
)
|
result['value'][name] = field.convert_to_write(
|
||||||
todo.add(name)
|
newval, record._origin, subfields.get(name),
|
||||||
|
)
|
||||||
|
todo.add(name)
|
||||||
|
else:
|
||||||
|
# keep result: newval may have been dirty before
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if newval != oldval:
|
||||||
|
# put new value in result
|
||||||
|
result['value'][name] = field.convert_to_write(
|
||||||
|
newval, record._origin, subfields.get(name),
|
||||||
|
)
|
||||||
|
todo.add(name)
|
||||||
|
else:
|
||||||
|
# clean up result to not return another value
|
||||||
|
result['value'].pop(name, None)
|
||||||
|
|
||||||
# At the moment, the client does not support updates on a *2many field
|
# At the moment, the client does not support updates on a *2many field
|
||||||
# while this one is modified by the user.
|
# while this one is modified by the user.
|
||||||
|
|
Loading…
Reference in New Issue