[FIX] core: in _auto_init, only log computation message if table is not empty

closes odoo/odoo#80687

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Victor Feyens
2021-12-01 17:09:00 +00:00
committed by Raphael Collet
parent 87224e158c
commit 2f1b15d982
+4 -3
View File
@@ -2848,9 +2848,10 @@ class BaseModel(metaclass=MetaModel):
# added to the database
cr.execute('SELECT id FROM "{}"'.format(self._table))
records = self.browse(row[0] for row in cr.fetchall())
for field in fields_to_compute:
_logger.info("Prepare computation of %s", field)
self.env.add_to_compute(field, records)
if records:
for field in fields_to_compute:
_logger.info("Prepare computation of %s", field)
self.env.add_to_compute(field, records)
if self._auto:
self._add_sql_constraints()