[IMP] ir_ui_view: do not recompute field `model_data_id` on views

The recomputation should not be necessary, as we normally don't change the
record referred by an ir_model_data record.  This speeds up the creation of
ir_model_data records by 33%, which should be noticeable during module
installations.
This commit is contained in:
Raphael Collet 2015-09-08 11:41:53 +02:00
parent ba74cb9144
commit 05f176f418
1 changed files with 1 additions and 10 deletions

View File

@ -118,11 +118,6 @@ class view(osv.osv):
result.update(map(itemgetter('res_id', 'id'), data_ids))
return result
def _views_from_model_data(self, cr, uid, ids, context=None):
IMD = self.pool['ir.model.data']
data_ids = IMD.search_read(cr, uid, [('id', 'in', ids), ('model', '=', 'ir.ui.view')], ['res_id'], context=context)
return map(itemgetter('res_id'), data_ids)
_columns = {
'name': fields.char('View Name', required=True),
'model': fields.char('Object', select=True),
@ -141,11 +136,7 @@ class view(osv.osv):
'inherit_id': fields.many2one('ir.ui.view', 'Inherited View', ondelete='restrict', select=True),
'inherit_children_ids': fields.one2many('ir.ui.view','inherit_id', 'Inherit Views'),
'field_parent': fields.char('Child Field'),
'model_data_id': fields.function(_get_model_data, type='many2one', relation='ir.model.data', string="Model Data",
store={
_name: (lambda s, c, u, i, ctx=None: i, None, 10),
'ir.model.data': (_views_from_model_data, ['model', 'res_id'], 10),
}),
'model_data_id': fields.function(_get_model_data, type='many2one', relation='ir.model.data', string="Model Data", store=True),
'xml_id': fields.function(osv.osv.get_xml_id, type='char', size=128, string="External ID",
help="ID of the view defined in xml file"),
'groups_id': fields.many2many('res.groups', 'ir_ui_view_group_rel', 'view_id', 'group_id',