[FIX] fields: avoid infinite recursion in convert_to_write
This commit is contained in:
@@ -1052,6 +1052,9 @@ class TestFields(common.TransactionCase):
|
||||
self.assertEqual(new_email.message._origin, msg0)
|
||||
self.assertEqual(new_email.body, "XXX")
|
||||
|
||||
# check that this does not generate an infinite recursion
|
||||
new_disc._convert_to_write(new_disc._cache)
|
||||
|
||||
def test_40_new_ref_origin(self):
|
||||
""" Test the behavior of new records with ref/origin. """
|
||||
Discussion = self.env['test_new_api.discussion']
|
||||
|
||||
+3
-1
@@ -2360,6 +2360,7 @@ class _RelationalMulti(_Relational):
|
||||
return value.ids
|
||||
|
||||
def convert_to_write(self, value, record):
|
||||
inv_names = {field.name for field in record._field_inverses[self]}
|
||||
# make result with new and existing records
|
||||
result = [(6, 0, [])]
|
||||
for record in value:
|
||||
@@ -2368,6 +2369,7 @@ class _RelationalMulti(_Relational):
|
||||
values = record._convert_to_write({
|
||||
name: record[name]
|
||||
for name in record._cache
|
||||
if name not in inv_names
|
||||
})
|
||||
result.append((0, 0, values))
|
||||
else:
|
||||
@@ -2376,7 +2378,7 @@ class _RelationalMulti(_Relational):
|
||||
values = record._convert_to_write({
|
||||
name: record[name]
|
||||
for name in record._cache
|
||||
if record[name] != origin[name]
|
||||
if name not in inv_names and record[name] != origin[name]
|
||||
})
|
||||
if values:
|
||||
result.append((1, origin.id, values))
|
||||
|
||||
Reference in New Issue
Block a user