[ADD] base: method to fetch an act_window from its xml_id on ir.actions.act_window
Also used it to replace the corresponding code in ir.attachment and res.widget.wizard bzr revid: xmo@openerp.com-20101125165720-62qphqpmt4fl2xcl
This commit is contained in:
@@ -272,6 +272,19 @@ class act_window(osv.osv):
|
||||
'multi': False,
|
||||
}
|
||||
|
||||
def for_xml_id(self, cr, uid, module, xml_id, context=None):
|
||||
""" Returns the act_window object created for the provided xml_id
|
||||
|
||||
:param module: the module the act_window originates in
|
||||
:param xml_id: the namespace-less id of the action (the @id
|
||||
attribute from the XML file)
|
||||
:return: A read() view of the ir.actions.act_window
|
||||
"""
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
data_id = dataobj._get_id (cr, 1, module, xml_id)
|
||||
res_id = dataobj.browse(cr, uid, data_id, context).res_id
|
||||
return self.read(cr, uid, res_id, [], context)
|
||||
|
||||
act_window()
|
||||
|
||||
class act_window_view(osv.osv):
|
||||
|
||||
@@ -81,10 +81,8 @@ class ir_attachment(osv.osv):
|
||||
return super(ir_attachment, self).create(cr, uid, values, context)
|
||||
|
||||
def action_get(self, cr, uid, context=None):
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
data_id = dataobj._get_id(cr, 1, 'base', 'action_attachment')
|
||||
res_id = dataobj.browse(cr, uid, data_id, context).res_id
|
||||
return self.pool.get('ir.actions.act_window').read(cr, uid, res_id, [], context)
|
||||
return self.pool.get('ir.actions.act_window').for_xml_id(
|
||||
cr, uid, 'base', 'action_attachment', context=context)
|
||||
|
||||
def _name_get_resname(self, cr, uid, ids, object,method, context):
|
||||
data = {}
|
||||
|
||||
@@ -49,11 +49,8 @@ class res_widget_wizard(osv.osv_memory):
|
||||
}
|
||||
|
||||
def action_get(self, cr, uid, context=None):
|
||||
dataobj = self.pool.get('ir.model.data')
|
||||
data_id = dataobj._get_id(cr, 1, 'base', 'action_res_widget_wizard')
|
||||
res_id = dataobj.browse(cr, uid, data_id, context).res_id
|
||||
return self.pool.get('ir.actions.act_window').read(
|
||||
cr, uid, res_id, [], context)
|
||||
return self.pool.get('ir.actions.act_window').for_xml_id(
|
||||
cr, uid, 'base', 'action_res_widget_wizard', context=context)
|
||||
|
||||
def res_widget_add(self, cr, uid, ids, context=None):
|
||||
wizard = self.read(cr, uid, ids, context=context)[0]
|
||||
|
||||
Reference in New Issue
Block a user