From 06c28f214e6b99e6cf2021f8d3aafc82dce60d08 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 11 Oct 2019 11:55:17 +0000 Subject: [PATCH] [FIX] models: infinite loop Example of workflow to reproduce the issue: - Add a selection field 'Test' to `project.task` with Studio - Go to Projects > Planning > By Project - Switch to list view - Add the newly created field to the view 'Task > Test' The interface loops indefinitely because the server is stuck in an infinite loop. The loop is the following: https://github.com/odoo/odoo/blob/89270ee39c0daa46ae8e2e3e57d7e512a1a65ddf/odoo/models.py#L5624-L5625 The root cause of the issue comes from an incorrect object ID added in the list of fields to recompute. Since the method is set in a `post_init`, the object `field` is different from `recs[field_name]`. To prevent the error, we retrieve the object directly in the `mark_fields_to_compute` method. opw-2083852 closes odoo/odoo#38550 X-original-commit: 446cd3f3d610c9a872969f5d6843ccb6ebdb0d40 Signed-off-by: Nicolas Martinelli (nim) Co-authored-by: Denis Ledoux --- odoo/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/models.py b/odoo/models.py index bd499ad9f9f..879b209e395 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -2408,7 +2408,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): continue # don't update custom fields new = field.update_db(self, columns) if new and field.compute: - fields_to_compute.append(field) + fields_to_compute.append(field.name) if fields_to_compute: @self.pool.post_init @@ -2416,7 +2416,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): recs = self.with_context(active_test=False).search([]) for field in fields_to_compute: _logger.info("Storing computed values of %s", field) - self.env.add_to_compute(field, recs) + self.env.add_to_compute(recs._fields[field], recs) if self._auto: self._add_sql_constraints()