summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2015-08-19 17:18:43 +0200
committerRaphael Collet <rco@openerp.com>2015-08-24 11:10:31 +0200
commit598acd7d4b3e8be2bb05bf0ed74c2e8fc334a56d (patch)
tree86b829241bbc8ab8d247c600c6b233c4d82664db
parent2d782da4368ffcceaff8ed76cd2f1ed54116e8ee (diff)
[IMP] ir_model: when renaming a column, also rename the corresponding index
-rw-r--r--openerp/addons/base/ir/ir_model.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py
index 4b12e0a8b9a..597fee4b384 100644
--- a/openerp/addons/base/ir/ir_model.py
+++ b/openerp/addons/base/ir/ir_model.py
@@ -502,7 +502,7 @@ class ir_model_fields(osv.osv):
raise UserError(_('New field name must still start with x_ , because it is a custom field!'))
if '\'' in vals['name'] or '"' in vals['name'] or ';' in vals['name']:
raise ValueError('Invalid character in column name')
- column_rename = (obj._table, item.name, vals['name'])
+ column_rename = (obj._table, item.name, vals['name'], bool(int(item.select_level)))
# We don't check the 'state', because it might come from the context
# (thus be set for multiple fields) and will be ignored anyway.
@@ -519,8 +519,11 @@ class ir_model_fields(osv.osv):
self.pool.clear_manual_fields()
if column_rename:
- # rename column in database
- cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO "%s"' % column_rename)
+ # rename column in database, and its corresponding index if present
+ table, oldname, newname, index = column_rename
+ cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO "%s"' % (table, oldname, newname))
+ if index:
+ cr.execute('ALTER INDEX "%s_%s_index" RENAME TO "%s_%s_index"' % (table, oldname, table, newname))
if column_rename or patched_models:
# setup models, this will reload all manual fields in registry