[IMP] models: only log "long name constraint" when the constraint is added

This way, we avoid spamming the log each time new constraints are added in the constraint's table.

closes odoo/odoo#132681

Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
This commit is contained in:
Miquel Raïch
2023-09-12 22:12:53 +00:00
parent 69d23262f8
commit c93a57ccab
+5 -3
View File
@@ -3109,10 +3109,12 @@ class BaseModel(metaclass=MetaModel):
conname = '%s_%s' % (self._table, key)
if len(conname) > 63:
hashed_conname = tools.make_identifier(conname)
_logger.info("Constraint name %r has more than 63 characters, internal PG identifier is %r", conname, hashed_conname)
current_definition = tools.constraint_definition(cr, self._table, hashed_conname)
if not current_definition:
_logger.info("Constraint name %r has more than 63 characters, internal PG identifier is %r", conname, hashed_conname)
conname = hashed_conname
current_definition = tools.constraint_definition(cr, self._table, conname)
else:
current_definition = tools.constraint_definition(cr, self._table, conname)
if current_definition == definition:
continue