[ADD] don't blow up on a singleton DELETE_ALL command (that command takes no parameters, so can have just (5,))
bzr revid: xmo@openerp.com-20111011084852-hborz317ru5pbzux
This commit is contained in:
parent
8734ffb6c2
commit
2646a34cf0
|
@ -4790,6 +4790,9 @@ class BaseModel(object):
|
||||||
for o2m_command in o2m_commands:
|
for o2m_command in o2m_commands:
|
||||||
if not isinstance(o2m_command, (list, tuple)):
|
if not isinstance(o2m_command, (list, tuple)):
|
||||||
commands.append((4, o2m_command, False))
|
commands.append((4, o2m_command, False))
|
||||||
|
elif len(o2m_command) == 1:
|
||||||
|
(command,) = o2m_command
|
||||||
|
commands.append((command, False, False))
|
||||||
elif len(o2m_command) == 2:
|
elif len(o2m_command) == 2:
|
||||||
command, id = o2m_command
|
command, id = o2m_command
|
||||||
commands.append((command, id, False))
|
commands.append((command, id, False))
|
||||||
|
|
|
@ -141,6 +141,16 @@ class TestO2MSerialization(unittest2.TestCase):
|
||||||
{'id': ids[2], 'name': 'baz'}
|
{'id': ids[2], 'name': 'baz'}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_singleton_commands(self):
|
||||||
|
"DELETE_ALL can appear as a singleton"
|
||||||
|
|
||||||
|
try:
|
||||||
|
list(self.partner.resolve_o2m_commands_to_record_dicts(
|
||||||
|
self.cr, UID, 'address', [(5,)], ['name']))
|
||||||
|
except AssertionError:
|
||||||
|
# 5 should fail with an assert error, but not e.g. a ValueError
|
||||||
|
pass
|
||||||
|
|
||||||
def test_invalid_commands(self):
|
def test_invalid_commands(self):
|
||||||
"Commands with uncertain semantics in this context should be forbidden"
|
"Commands with uncertain semantics in this context should be forbidden"
|
||||||
|
|
||||||
|
@ -159,3 +169,4 @@ class TestO2MSerialization(unittest2.TestCase):
|
||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
list(self.partner.resolve_o2m_commands_to_record_dicts(
|
list(self.partner.resolve_o2m_commands_to_record_dicts(
|
||||||
self.cr, UID, 'address', [REPLACE_WITH([42])], ['name']))
|
self.cr, UID, 'address', [REPLACE_WITH([42])], ['name']))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue