summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorChristophe Monniez <moc@odoo.com>2021-03-03 12:33:20 +0000
committerRaphael Collet <rco@odoo.com>2021-03-03 13:24:52 +0000
commitd39855bad5153654d443d1b7ede3907f8bae3e66 (patch)
treee1a5bc569cdad9785bfff798b483bb334dd466e3 /odoo/models.py
parentf4136c3188e4f5df68a01f57d7d09ecf96be63b6 (diff)
[FIX] models: call inverse method right after cache invalidation
When a record is written on a computed field with an inverse method and an x2many field wit a delete command, the computed field is not properly handled by the inverse method, because of a whole cache invalidation that happens during the unlink. With this commit, we write in cache on the fields that have been invalidated before invoking the inverse method. opw #2439861 closes odoo/odoo#67152 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com> Co-authored-by: Raphael Collet <rco@odoo.com>
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 1f4c5ba0e2b..6bd10fde74a 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -3688,6 +3688,11 @@ Fields:
real_recs._validate_fields(vals, inverse_fields)
for fields in determine_inverses.values():
+ # write again on non-stored fields that have been invalidated from cache
+ for field in fields:
+ if not field.store and any(self.env.cache.get_missing_ids(real_recs, field)):
+ field.write(real_recs, vals[field.name])
+
# inverse records that are not being computed
try:
fields[0].determine_inverse(real_recs)