From 75343583512420d8a5a22bec4cc2eb754a93e435 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Wed, 23 Feb 2022 11:21:55 +0000 Subject: [PATCH] Revert "[IMP] base: make `recompute` faster" This reverts commit 59ea46c97e004607744d4756dc16c98df633f427. Part-of: odoo/odoo#85199 --- odoo/models.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/odoo/models.py b/odoo/models.py index a3a7688d545..8eb1f5ad2c3 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -6141,9 +6141,9 @@ Fields: """ def process(field): recs = self.env.records_to_compute(field) - if (not recs) or (records is not None and not (records & recs)): + if not recs: return - if field.store: + if field.compute and field.store: # do not force recomputation on new records; those will be # recomputed by accessing the field on the records recs = recs.filtered('id') @@ -6166,11 +6166,18 @@ Fields: for field in list(self.env.fields_to_compute()): process(field) else: + fields = [self._fields[fname] for fname in fnames] + + # check whether any 'records' must be computed + if records is not None and not any( + records & self.env.records_to_compute(field) + for field in fields + ): + return + # recompute the given fields on self's model - for fname in fnames: - field = self._fields[fname] - if field.compute: - process(field) + for field in fields: + process(field) # # Generic onchange method