summaryrefslogtreecommitdiff
path: root/odoo
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:26 +0000
commitb491ca0bb37dc3b4eb6366cb7fc7518219a59684 (patch)
treed014bc17e1c783e1734ebdc59048b59ade9a3a69 /odoo
parentdb276e4d9915ae19ec162409a3a106baac03b26a (diff)
[IMP] core: avoid duplicates in `depends` and `depends_context`
Repeated calls to `registry.setup_models()` will eventually introduce many duplicates in the those attributes, which may slow down the determination of computation triggers. X-original-commit: 735e65f7ca45616881336121d10a874412446dcf Co-authored-by: Xavier Morel <xmo@odoo.com>
Diffstat (limited to 'odoo')
-rw-r--r--odoo/fields.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index 2d38e9ff8e3..84d1dad8b40 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -473,7 +473,8 @@ class Field(MetaField('DummyField', (object,), {})):
# display_name may depend on context['lang'] (`test_lp1071710`)
if self.automatic and self.name == 'display_name' and model._rec_name:
if model._fields[model._rec_name].base_field.translate:
- self.depends_context += ('lang',)
+ if 'lang' not in self.depends_context:
+ self.depends_context += ('lang',)
#
# Setup of related fields
@@ -2897,11 +2898,11 @@ class _RelationalMulti(_Relational):
def _setup_regular_full(self, model):
super(_RelationalMulti, self)._setup_regular_full(model)
if isinstance(self.domain, list):
- self.depends += tuple(
+ self.depends = tuple(unique(itertools.chain(self.depends, (
self.name + '.' + arg[0]
for arg in self.domain
if isinstance(arg, (tuple, list)) and isinstance(arg[0], str)
- )
+ ))))
def create(self, record_values):
""" Write the value of ``self`` on the given records, which have just