From 6bd9e71d9d54ea541a107846543e4de463be7132 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 11 Apr 2019 06:26:17 +0000 Subject: [PATCH] [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) --- odoo/tests/common.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 507d023fc98..df6c626906b 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -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