From ef01493678e9ecd5a74ad6d5c9d78bb1ecb9b991 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 20 Jul 2020 09:24:12 +0000 Subject: [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) --- odoo/fields.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'odoo/fields.py') diff --git a/odoo/fields.py b/odoo/fields.py index 31d67bc6556..4695eb2c43d 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -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: -- cgit v1.2.3