From 5fa1256bb6f0612bbc4d980500ee20c76e05c5a0 Mon Sep 17 00:00:00 2001 From: Nicolas Seinlet Date: Mon, 22 Feb 2021 13:50:09 +0000 Subject: [PATCH] [FIX] registry: no name in constraint check When table name is long enough, the foreign key constraint name computed by odoo and the one by PostgreSQL are different, for the same table, column and definition, are different. As an example, base_partner_merge_automatic_wizard_res_partner_rel(partner_id) foreign key is named base_partner_merge_automatic_wizard_res_partner_rel_res_partner_id_fkey in Odoo while it's base_partner_merge_automatic_wizard_res_par_res_partner_id_fkey in PostgreSQL. This difference trigger a useless foreign key drop/create. closes odoo/odoo#67601 X-original-commit: 353b415c74da057d5e81cce4d309bebb5f0f2927 Signed-off-by: Raphael Collet (rco) --- odoo/modules/registry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index 91ba425b362..fdcacab7c32 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -495,7 +495,7 @@ class Registry(Mapping): if spec is None: sql.add_foreign_key(cr, table1, column1, table2, column2, ondelete) model.env['ir.model.constraint']._reflect_constraint(model, conname, 'f', None, module) - elif spec != (conname, table2, column2, deltype): + elif (spec[1], spec[2], spec[3]) != (table2, column2, deltype): sql.drop_constraint(cr, table1, spec[0]) sql.add_foreign_key(cr, table1, column1, table2, column2, ondelete) model.env['ir.model.constraint']._reflect_constraint(model, conname, 'f', None, module)