[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) <nim@odoo.com> Co-authored-by: Denis Ledoux <dle@odoo.com>
This commit is contained in:
committed by
fw-bot
co-authored by
Denis Ledoux
parent
6677ea104a
commit
06c28f214e
+2
-2
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user