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:27 +0000
commitf694caac416cd66c3878cf6352855cb9765c3b45 (patch)
tree31d0c9e4a2acb830cd9cae253cf1a3a04ec7b326 /odoo/fields.py
parentb491ca0bb37dc3b4eb6366cb7fc7518219a59684 (diff)
[IMP] core: optimize `model._setup_base()`
Simplify the code to retrieve fields on a class. Simplify the class attribute that lists the class' proper fields. Optimize `model._add_inherited_fields()`. Optimize `resolve_mro` by using classes instead of recordsets. This saves 3.5% of the total installation time. X-original-commit: 89ab71905cb6c5d3beda5eac357f8592e31aaef8
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index 84d1dad8b40..2420f1090b5 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -55,12 +55,13 @@ def resolve_mro(model, name, predicate):
(the ones that appear in the registry) are ignored.
"""
result = []
- for cls in type(model).__mro__:
- if not getattr(cls, 'pool', None) and name in cls.__dict__:
- value = cls.__dict__[name]
- if not predicate(value):
- break
- result.append(value)
+ for cls in model._model_classes:
+ value = cls.__dict__.get(name, Default)
+ if value is Default:
+ continue
+ if not predicate(value):
+ break
+ result.append(value)
return result