From 13f02a60c8706b808a57535ac9648a1b0c0741a9 Mon Sep 17 00:00:00 2001
From: Nicolas Seinlet <nse@openerp.com>
Date: Tue, 23 Feb 2021 13:34:04 +0000
Subject: [PATCH] [FIX] registry: avoid dropping indexes

When an index has name 'tablename_fieldname_index', this index is
dropped if the field has index=False.  This lead to dropping a
user-created index or dropping/recreating the index when index=True is
set in a dependent module.  Some info is logged instead.

closes odoo/odoo#66700

closes odoo/odoo#71761

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
---
 odoo/fields.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/odoo/fields.py b/odoo/fields.py
index 28b2088eec42..195cc269d7f1 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -1003,7 +1003,7 @@ class Field(MetaField('DummyField', (object,), {})):
             except psycopg2.OperationalError:
                 _schema.error("Unable to add index for %s", self)
         else:
-            sql.drop_index(model._cr, indexname, model._table)
+            _schema.info("Keep unexpected index %s on table %s", indexname, model._table)
 
     def update_db_related(self, model):
         """ Compute a stored related field directly in SQL. """
-- 
GitLab