[FIX] core: writing on one2many field on new record
When using command "6" (SET), the one2many field's inverse was not assigned on the lines. closes odoo/odoo#65675 X-original-commit: ba733a9ac73dcf978ed7eaab7681781b2d5a9bfc Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
@@ -1693,6 +1693,13 @@ class TestFields(TransactionCaseWithUserDemo):
|
||||
self.assertFalse(new_move.line_ids.id)
|
||||
self.assertEqual(new_move.line_ids.quantity, 2)
|
||||
|
||||
# assign line to new move without origin
|
||||
new_move = move.new()
|
||||
new_move.line_ids = line
|
||||
self.assertFalse(new_move.line_ids.id)
|
||||
self.assertEqual(new_move.line_ids._origin, line)
|
||||
self.assertEqual(new_move.line_ids.move_id, new_move)
|
||||
|
||||
@mute_logger('odoo.addons.base.models.ir_model')
|
||||
def test_41_new_related(self):
|
||||
""" test the behavior of related fields starting on new records. """
|
||||
|
||||
+7
-4
@@ -3428,11 +3428,14 @@ class One2many(_RelationalMulti):
|
||||
browse([command[1]])[inverse] = False
|
||||
elif command[0] == Command.LINK:
|
||||
browse([command[1]])[inverse] = recs[-1]
|
||||
elif command[0] in (Command.CLEAR, Command.SET):
|
||||
elif command[0] == Command.CLEAR:
|
||||
cache.update(recs, self, itertools.repeat(()))
|
||||
elif command[0] == Command.SET:
|
||||
# assign the given lines to the last record only
|
||||
cache.update(recs, self, [()] * len(recs))
|
||||
lines = comodel.browse(command[2] if command[0] == Command.SET else [])
|
||||
cache.set(recs[-1], self, lines._ids)
|
||||
cache.update(recs, self, itertools.repeat(()))
|
||||
last, lines = recs[-1], browse(command[2])
|
||||
cache.set(last, self, lines._ids)
|
||||
cache.update(lines, inverse_field, itertools.repeat(last.id))
|
||||
|
||||
else:
|
||||
def link(record, lines):
|
||||
|
||||
Reference in New Issue
Block a user