[FIX] fields: x2many value overrides default value on new records
When instantiating a new record, the commands of an x2many field apply on an empty recordset instead of the field's default value. This is less bug-prone, and avoids an infinite recursion in `convert_to_cache`.
This commit is contained in:
@@ -958,9 +958,9 @@ class TestFields(common.TransactionCase):
|
||||
# no value gives the default value
|
||||
new_disc = discussion.new({'name': "Foo"})
|
||||
self.assertEqual(new_disc.categories._origin, cat1)
|
||||
# value is combined with default value
|
||||
# value overrides default value
|
||||
new_disc = discussion.new({'name': "Foo", 'categories': [(4, cat2.id)]})
|
||||
self.assertEqual(new_disc.categories._origin, cat1 + cat2)
|
||||
self.assertEqual(new_disc.categories._origin, cat2)
|
||||
|
||||
def test_40_new_fields(self):
|
||||
""" Test new records with relational fields. """
|
||||
|
||||
+1
-1
@@ -2321,7 +2321,7 @@ class _RelationalMulti(_Relational):
|
||||
else:
|
||||
browse = comodel.browse
|
||||
# determine the value ids
|
||||
ids = OrderedSet(record[self.name]._ids)
|
||||
ids = OrderedSet(record[self.name]._ids if validate else ())
|
||||
# modify ids with the commands
|
||||
for command in value:
|
||||
if isinstance(command, (tuple, list)):
|
||||
|
||||
Reference in New Issue
Block a user