[MERGE] forward port of branch 7.0 up to f4cb884

This commit is contained in:
Christophe Simonis 2016-05-17 13:16:50 +02:00
commit 393c14d31a
7 changed files with 19 additions and 9 deletions

View File

@ -372,10 +372,11 @@ class ir_actions_act_window_view(osv.osv):
'multi': False,
}
def _auto_init(self, cr, context=None):
super(ir_actions_act_window_view, self)._auto_init(cr, context)
res = super(ir_actions_act_window_view, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'act_window_view_unique_mode_per_action\'')
if not cr.fetchone():
cr.execute('CREATE UNIQUE INDEX act_window_view_unique_mode_per_action ON ir_act_window_view (act_window_id, view_mode)')
return res
class ir_actions_act_window_close(osv.osv):

View File

@ -215,11 +215,12 @@ class ir_attachment(osv.osv):
}
def _auto_init(self, cr, context=None):
super(ir_attachment, self)._auto_init(cr, context)
res = super(ir_attachment, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('ir_attachment_res_idx',))
if not cr.fetchone():
cr.execute('CREATE INDEX ir_attachment_res_idx ON ir_attachment (res_model, res_id)')
cr.commit()
return res
def check(self, cr, uid, ids, mode, context=None, values=None):
"""Restricts the access to an ir.attachment, according to referred model

View File

@ -878,10 +878,11 @@ class ir_model_data(osv.osv):
type(self).loads = self.pool.model_data_reference_ids
def _auto_init(self, cr, context=None):
super(ir_model_data, self)._auto_init(cr, context)
res = super(ir_model_data, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_model_data_module_name_index\'')
if not cr.fetchone():
cr.execute('CREATE INDEX ir_model_data_module_name_index ON ir_model_data (module, name)')
return res
# NEW V8 API
@tools.ormcache(skiparg=3)

View File

@ -241,7 +241,7 @@ class ir_translation(osv.osv):
'Language code of translation item must be among known languages' ), ]
def _auto_init(self, cr, context=None):
super(ir_translation, self)._auto_init(cr, context)
res = super(ir_translation, self)._auto_init(cr, context)
# FIXME: there is a size limit on btree indexed values so we can't index src column with normal btree.
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('ir_translation_ltns',))
@ -265,6 +265,8 @@ class ir_translation(osv.osv):
cr.execute('CREATE INDEX ir_translation_ltn ON ir_translation (name, lang, type)')
cr.commit()
return res
def _check_selection_field_value(self, cr, uid, field, value, context=None):
if field == 'lang':
return

View File

@ -93,10 +93,11 @@ class view_custom(osv.osv):
def _auto_init(self, cr, context=None):
super(view_custom, self)._auto_init(cr, context)
res = super(view_custom, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_custom_user_id_ref_id\'')
if not cr.fetchone():
cr.execute('CREATE INDEX ir_ui_view_custom_user_id_ref_id ON ir_ui_view_custom (user_id, ref_id)')
return res
def _hasclass(context, *cls):
""" Checks if the context node has all the classes passed as arguments
@ -227,10 +228,11 @@ class view(osv.osv):
]
def _auto_init(self, cr, context=None):
super(view, self)._auto_init(cr, context)
res = super(view, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_ui_view_model_type_inherit_id\'')
if not cr.fetchone():
cr.execute('CREATE INDEX ir_ui_view_model_type_inherit_id ON ir_ui_view (model, inherit_id)')
return res
def _compute_defaults(self, cr, uid, values, context=None):
if 'inherit_id' in values:

View File

@ -184,10 +184,11 @@ class ir_values(osv.osv):
}
def _auto_init(self, cr, context=None):
super(ir_values, self)._auto_init(cr, context)
res = super(ir_values, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_values_key_model_key2_res_id_user_id_idx\'')
if not cr.fetchone():
cr.execute('CREATE INDEX ir_values_key_model_key2_res_id_user_id_idx ON ir_values (key, model, key2, res_id, user_id)')
return res
def create(self, cr, uid, vals, context=None):
res = super(ir_values, self).create(cr, uid, vals, context=context)

View File

@ -160,13 +160,14 @@ class wkf_instance(osv.osv):
'transition_ids': fields.many2many('workflow.transition', 'wkf_witm_trans', 'inst_id', 'trans_id'),
}
def _auto_init(self, cr, context=None):
super(wkf_instance, self)._auto_init(cr, context)
res = super(wkf_instance, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_type_res_id_state_index\'')
if not cr.fetchone():
cr.execute('CREATE INDEX wkf_instance_res_type_res_id_state_index ON wkf_instance (res_type, res_id, state)')
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_instance_res_id_wkf_id_index\'')
if not cr.fetchone():
cr.execute('CREATE INDEX wkf_instance_res_id_wkf_id_index ON wkf_instance (res_id, wkf_id)')
return res
wkf_instance()
@ -195,10 +196,11 @@ class wkf_triggers(osv.osv):
'workitem_id': fields.many2one('workflow.workitem', 'Workitem', required=True, ondelete="cascade"),
}
def _auto_init(self, cr, context=None):
super(wkf_triggers, self)._auto_init(cr, context)
res = super(wkf_triggers, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_triggers_res_id_model_index\'')
if not cr.fetchone():
cr.execute('CREATE INDEX wkf_triggers_res_id_model_index ON wkf_triggers (res_id, model)')
return res
wkf_triggers()