summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-04-02 06:45:54 +0000
committerRaphael Collet <rco@odoo.com>2020-04-03 11:40:28 +0000
commit0551e7ad54bea744fc546682a0070327807d5e36 (patch)
tree5143cb66e4975c15324c18731dd8e5d7889aeebf /odoo/fields.py
parent8b94e53084db3d32ec738f4fbf5639e8b6053bb5 (diff)
[IMP] core: compute field triggers lazily on registry
This saves 2% of the total installation time. X-original-commit: 6a0028f91944b1d9e4eac026e86ca249ef5bc7ee
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index ad0c167588f..2f4764f6233 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -594,18 +594,22 @@ class Field(MetaField('DummyField', (object,), {})):
# Setup of field triggers
#
- def resolve_depends(self, model):
+ def resolve_depends(self, registry):
""" Return the dependencies of `self` as a collection of field tuples. """
+ Model0 = registry[self.model_name]
+
for dotnames in self.depends:
field_seq = []
- field_model = model
+ model_name = self.model_name
+
for index, fname in enumerate(dotnames.split('.')):
- if model._transient and not field_model._transient:
+ Model = registry[model_name]
+ if Model0._transient and not Model._transient:
# modifying fields on regular models should not trigger
# recomputations of fields on transient models
break
- field = field_model._fields[fname]
+ field = Model._fields[fname]
if field is self and index:
self.recursive = True
@@ -618,10 +622,10 @@ class Field(MetaField('DummyField', (object,), {})):
yield tuple(field_seq)
if field.type in ('one2many', 'many2many'):
- for inv_field in field_model._field_inverses[field]:
+ for inv_field in Model._field_inverses[field]:
yield tuple(field_seq) + (inv_field,)
- field_model = model.env.get(field.comodel_name)
+ model_name = field.comodel_name
############################################################################
#