From c93a57ccab626b4ff2f6940f9a5905b602c796fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Tue, 22 Aug 2023 13:55:22 +0200 Subject: [PATCH] [IMP] models: only log "long name constraint" when the constraint is added MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- odoo/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/odoo/models.py b/odoo/models.py index 4df1724d87c..47a08221071 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -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