summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-07-20 09:24:12 +0000
committerRaphael Collet <rco@odoo.com>2020-07-20 11:42:59 +0000
commitef01493678e9ecd5a74ad6d5c9d78bb1ecb9b991 (patch)
tree880e13c380f1998e3a5c425972279bd98f099a50 /odoo
parentb3761a8cba6f24bbcb4b35f14e076965d1210f69 (diff)
[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>
Diffstat (limited to 'odoo')
-rw-r--r--odoo/fields.py5
1 files changed, 5 insertions, 0 deletions
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: