[FIX] core: update of one2many field on new record with origin

When setting the inverse many2one field on a record, the record is not
removed from its inverse relation if the field's current value is not in
cache.  Fix this by setting the field's value in cache before updating.

closes odoo/odoo#54711

X-original-commit: df12c85816dfa59f298c3e6a077bd88e4b7aa6a6
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
Raphael Collet
2020-07-20 11:42:59 +00:00
parent b3761a8cba
commit ef01493678
+5
View File
@@ -3173,6 +3173,11 @@ class One2many(_RelationalMulti):
if self.store:
inverse = self.inverse_name
# make sure self's inverse is in cache
inverse_field = comodel._fields[inverse]
for record in records:
cache.update(record[self.name], inverse_field, itertools.repeat(record.id))
for recs, commands in records_commands_list:
for command in commands:
if command[0] == 0: