[FIX] SSF: misinterpretation of onchange command (4)

From an onchange, at this point, (4) doesn't mean "no change" it means
"reset to database values". Through the interplay of client and server
reverse-engineering one another at this point the client (is supposed
to) assume the o2m results are "complete" and a diff from the
current *in-database* values rather than the in-client (sent to the
server) ones.

So a (1) should completely replace all existing values, and a (4)
should just remove all of them (but keep the record linked).

closes odoo/odoo#32617

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
Xavier Morel
2019-04-11 07:49:21 +00:00
parent 5a83cd2649
commit 6bd9e71d9d
+6 -3
View File
@@ -1461,12 +1461,13 @@ class Form(object):
return []
v = []
c = {t[1]: t[2] for t in current if t[0] in (1, 2)} if current else {}
c = {t[1] for t in current if t[0] in (1, 2)} if current else set()
# which view should this be???
subfields = descr['views']['edition']['fields']
# TODO: simplistic, unlikely to work if e.g. there's a 5 inbetween other commands
for command in value:
if command[0] in (0, 1):
c.pop(command[1], None) # remove record from currents
c.discard(command[1])
v.append((command[0], command[1], {
k: self._cleanup_onchange(
subfields[k], v, None
@@ -1475,9 +1476,11 @@ class Form(object):
if k in subfields
}))
elif command[0] == 2:
c.discard(command[1])
v.append((2, command[1], False))
elif command[0] == 4:
v.append((1, command[1], c.pop(command[1], {})))
c.discard(command[1])
v.append((1, command[1], {}))
elif command[0] == 5:
v = []
# explicitly mark all non-relinked (or modified) records as deleted