summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2018-01-04 15:22:17 +0100
committerRaphael Collet <rco@odoo.com>2018-01-12 13:42:05 +0100
commit3fbd86bcbe6dffe923e10d4690ee302c6a779f90 (patch)
tree903b69236072bc34212c83c92a2f125ec0a4a986 /odoo/fields.py
parent9f4c1646bc64f870082f22abd9ba6b2b65a2945a (diff)
[IMP] field: compute transitive dependencies over non-stored fields
In other words, when a field F depends on a non-stored field G, it also depends on G's dependencies. This guarantees that whenever a dependency of G is modified, F will be invalidated and marked to recompute (if necessary). The transitive closure of dependencies is not computed over stored fields. Anyway stored fields already trigger the recomputation of their dependent fields during their recomputation. The performance impact on the loading of a registry is negligible (less than 1%), and the increase of recomputation triggers is small (less than 10%).
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index b6b13e97c8c..2e3d4d7eed2 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -658,7 +658,7 @@ class Field(MetaField('DummyField', (object,), {})):
# on ``path``. See method ``modified`` below for details.
#
- def resolve_deps(self, model):
+ def resolve_deps(self, model, path0=[], seen=frozenset()):
""" Return the dependencies of ``self`` as tuples ``(model, field, path)``,
where ``path`` is an optional list of field names.
"""
@@ -669,11 +669,12 @@ class Field(MetaField('DummyField', (object,), {})):
for dotnames in self.depends:
if dotnames == self.name:
_logger.warning("Field %s depends on itself; please fix its decorator @api.depends().", self)
- model, path = model0, dotnames.split('.')
- for i, fname in enumerate(path):
+ model, path = model0, path0
+ for fname in dotnames.split('.'):
field = model._fields[fname]
- result.append((model, field, path[:i]))
+ result.append((model, field, path))
model = model0.env.get(field.comodel_name)
+ path = None if path is None else path + [fname]
# add self's model dependencies
for mname, fnames in model0._depends.items():
@@ -683,11 +684,14 @@ class Field(MetaField('DummyField', (object,), {})):
result.append((model, field, None))
# add indirect dependencies from the dependencies found above
+ seen = seen.union([self])
for model, field, path in list(result):
for inv_field in model._field_inverses[field]:
inv_model = model0.env[inv_field.model_name]
inv_path = None if path is None else path + [field.name]
result.append((inv_model, inv_field, inv_path))
+ if not field.store and field not in seen:
+ result += field.resolve_deps(model, path, seen)
return result