[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
|
||||
for name, oldval in values.iteritems():
|
||||
newval = record[name]
|
||||
field = self._fields[name]
|
||||
if newval != oldval or \
|
||||
field.type in ('one2many', 'many2many') and newval._dirty:
|
||||
result['value'][name] = field.convert_to_write(
|
||||
newval, record._origin, subfields.get(name),
|
||||
)
|
||||
todo.add(name)
|
||||
newval = record[name]
|
||||
if field.type in ('one2many', 'many2many'):
|
||||
if newval != oldval or newval._dirty:
|
||||
# put new value in result
|
||||
result['value'][name] = field.convert_to_write(
|
||||
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
|
||||
# while this one is modified by the user.
|
||||
|
|
Loading…
Reference in New Issue