summaryrefslogtreecommitdiff
path: root/odoo/api.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2019-08-27 09:51:04 +0000
committerRaphael Collet <rco@odoo.com>2019-09-09 13:18:48 +0000
commitcfb08e87b0fa8895ec4406c9b30d2ebdb790e346 (patch)
tree4ac1ff2d8a34e3fb215dfb6b562f287fea71bf34 /odoo/api.py
parent3d2df88ffd5cfb9644bc54744a6c9b9a7fcfc264 (diff)
[FIX] models: use transitive triggers instead of recursion
On average, this reduces the total time spent in method `modified` by half (times measured on invoice creation and post).
Diffstat (limited to 'odoo/api.py')
-rw-r--r--odoo/api.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/odoo/api.py b/odoo/api.py
index efd1a748d3f..88cc4c9490c 100644
--- a/odoo/api.py
+++ b/odoo/api.py
@@ -636,14 +636,16 @@ class Environment(Mapping):
""" Return whether ``field`` must be computed on ``record``. """
return record.id in self.all.tocompute.get(field, ())
+ def not_to_compute(self, field, records):
+ """ Return the subset of ``records`` for which ``field`` must not be computed. """
+ ids = self.all.tocompute.get(field, ())
+ return records.browse(id_ for id_ in records._ids if id_ not in ids)
+
def add_to_compute(self, field, records):
- """ Mark ``field`` to be computed on ``records``, return newly added records. """
+ """ Mark ``field`` to be computed on ``records``. """
if not records:
return records
- ids = self.all.tocompute[field]
- added_ids = [id_ for id_ in records._ids if id_ not in ids]
- ids.update(added_ids)
- return records.browse(added_ids)
+ self.all.tocompute[field].update(records._ids)
def remove_to_compute(self, field, records):
""" Mark ``field`` as computed on ``records``. """