summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-12-13 15:27:27 +0000
committerRaphael Collet <rco@odoo.com>2020-12-18 14:00:03 +0000
commitba4665ce8267b020f6dc81bb7d36875b60f64f66 (patch)
tree400a10f07fe5d49be5742cb46a0cc7f4dbccd697 /odoo/fields.py
parentea6952fd7ec881b79a7294c40427ce9966997e66 (diff)
[FIX] core: marking and traversing computed fields before modification
This fixes an issue that occurs when marking fields to compute in the following situation: - it occurs before the actual modification, - a relational field is marked to compute, - the same field is traversed to inverse some dependency. When the marking occurs after the modification, the traversal of the field should actually recompute the field. However, if the marking occurs before the modification, the inversion of dependencies must be based on the current value of the field. This is the case with method unlink(): we call method modified() to mark the fields that currently depend on the records to be deleted, and the fields must be computed only after the deletion! X-original-commit: 3a6ac95ddf6a8719aa714a83fc339ba838c3811d
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index 8ddc0c1b422..4514c62baab 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -1097,10 +1097,10 @@ class Field(MetaField('DummyField', (object,), {})):
# new records: no business logic
new_records = records.browse(new_ids)
with records.env.protecting(records.pool.field_computed.get(self, [self]), records):
- new_records.modified([self.name])
- self.write(new_records, value)
if self.relational:
- new_records.modified([self.name])
+ new_records.modified([self.name], before=True)
+ self.write(new_records, value)
+ new_records.modified([self.name])
if self.inherited:
# special case: also assign parent records if they are new