diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-04-09 12:16:06 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-04-09 12:16:06 +0200 |
| commit | 6c8e30cae6ca5e4fe12e287ebd29d76544be57a3 (patch) | |
| tree | cce147099046ba971a817b2a5b70fbd2f054c9d0 /odoo/fields.py | |
| parent | 288d82a67137e206d30aaf572584e99cbee997b2 (diff) | |
| parent | 6d4940675f18dbb98d1f3882863ee10e7a1e3a49 (diff) | |
[MERGE] forward port branch saas-12.1 up to 6d4940675f1
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 6 |
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) |
