From 8ed3641f81502d3a7e9c9bb93771c6f5601a31a9 Mon Sep 17 00:00:00 2001
From: "Paolo (pgi)" <pgi@odoo.com>
Date: Wed, 27 Oct 2021 22:21:47 +0000
Subject: [PATCH] [FIX] base: invalid UNIQUE constraint just warn

When a submodule overrides an old UNIQUE constraint with a new one,
records in that module may respect the new one and not the old one.
As the old module is updated, it would fail giving an ERROR message,
and therefore blocking the Odoo.sh deployment pipeline.

i.e. website_sale (old): res_users_login_key -> ['login', 'website_id']
             base (new): res_users_login_key -> ['login']

With this patch, the error level is changed from ERROR to WARNING,
leaving Odoo.sh free to continue the build deployment, as the error
was not a blocking one.

closes odoo/odoo#79042

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
---
 odoo/modules/registry.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index 22aa8f10baeb..e3c74d082a42 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -341,7 +341,9 @@ class Registry(Mapping):
             try:
                 func(*args, **kwargs)
             except Exception as e:
-                _schema.error(*e.args)
+                # warn only, this is not a deployment showstopper, and
+                # can sometimes be a transient error
+                _schema.warning(*e.args)
 
     def init_models(self, cr, model_names, context, install=True):
         """ Initialize a list of models (given by their name). Call methods
-- 
GitLab