summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-05-08 08:36:08 +0000
committerRaphael Collet <rco@odoo.com>2020-05-08 11:33:38 +0000
commit5fc9b8c44acc424f4e365b4d492dda93c03ddfcf (patch)
tree7d32dba84b838bf460661d6dad4b0b786dd61172 /odoo/fields.py
parent12c6eba84463a7758bc79f05fb5a6a2508ae5ddc (diff)
[FIX] core: partial unlink in recordset
The following loop crashes on the second iteration: for record in records: record.display_name # access non-stored computed field record.unlink() # delete record The cache has been invalidated by `unlink` on the first iteration, so the field is computed. The computation is done on the whole recordset, which fails with a `MissingError` because of the first record. The fix is to retry the recomputation on the single record in this case. closes odoo/odoo#50910 X-original-commit: 7f33ebf528b1415452ce549e3329c3fe89be0ad8 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index 23eb491b0bc..a958695b618 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -914,7 +914,7 @@ class Field(MetaField('DummyField', (object,), {})):
recs = record if self.recursive else env.records_to_compute(self)
try:
self.compute_value(recs)
- except AccessError:
+ except (AccessError, MissingError):
self.compute_value(record)
try:
@@ -949,7 +949,7 @@ class Field(MetaField('DummyField', (object,), {})):
recs = record if self.recursive else record._in_cache_without(self)
try:
self.compute_value(recs)
- except AccessError:
+ except (AccessError, MissingError):
self.compute_value(record)
value = env.cache.get(record, self)