summaryrefslogtreecommitdiff
path: root/odoo/fields.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-04-10 15:10:24 +0200
committerChristophe Simonis <chs@odoo.com>2019-04-10 15:10:24 +0200
commite145f2b0c8831ec8756307b6b70c82f8dcdcab54 (patch)
tree93406d01e313cfecdeac03132c1cccb55ff05088 /odoo/fields.py
parent3f95b074e959f0f4ac93fbf4048c0c7276f2c17a (diff)
parent2694174b410f14ca81f0681ff4ae6856ff459ced (diff)
[MERGE] forward port branch saas-12.2 up to 2694174b410
Diffstat (limited to 'odoo/fields.py')
-rw-r--r--odoo/fields.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/odoo/fields.py b/odoo/fields.py
index 16a13bedbe4..0f729ba924b 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -945,7 +945,11 @@ class Field(MetaField('DummyField', (object,), {})):
"""
indexname = '%s_%s_index' % (model._table, self.name)
if self.index:
- sql.create_index(model._cr, indexname, model._table, ['"%s"' % self.name])
+ try:
+ with model._cr.savepoint():
+ sql.create_index(model._cr, indexname, model._table, ['"%s"' % self.name])
+ except psycopg2.OperationalError:
+ _schema.error("Unable to add index for %s", self)
else:
sql.drop_index(model._cr, indexname, model._table)