[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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user