首先,我想创建一个OpenERP
带有按钮的表单。单击该按钮时,该按钮将链接到project.issue表单。
按钮上应该写什么来执行这样的任务?
我正在使用开发者模式OpenERP
。
问问题
7138 次
3 回答
3
从 xml 文件中调用此方法,通过按钮,如
<button name="method_name" string="Open Form" type="object">
def method_name(self, cr, uid, ids, context=None):
"""Method is used to show form view in new windows"""
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'module_name', 'form_view_id')
view_id = view_ref and view_ref[1] or False,
this = self.browse(cr, uid, ids, context=context)[0]
return {
'type': 'ir.actions.act_window',
'name': 'Form heading',
'view_mode': 'form',
'view_type': 'form',
'view_id': view_id,
'res_model': 'module.name',
'nodestroy': True,
'res_id': this.id, # assuming the many2one
'target':'new',
'context': context,
}
其中:form_view_id,您要显示哪个视图...希望对您有所帮助。
于 2013-07-11T07:44:33.327 回答
0
你必须写一些这样的东西。
def open_sale_order_lines(self,cr,uid,ids,context=None):
if context is None:
context = {}
sale_ids = self.pool.get('sale.order').search(cr,uid,[('project_id','=',context.get('search_default_project_id',False)),('partner_id','in',context.get('search_default_partner_id',False))])
names = [record.name for record in self.browse(cr, uid, ids, context=context)]
name = _('Sales Order Lines of %s') % ','.join(names)
return {
'type': 'ir.actions.act_window',
'name': name,
'view_type': 'form',
'view_mode': 'tree,form',
'context': context,
'domain' : [('order_id','in',sale_ids)],
'res_model': 'sale.order.line',
'nodestroy': True,
}
于 2013-07-09T07:32:19.527 回答
0
需要注意的一点,在您返回的窗口操作中,您可以添加一个“目标”值。这类似于 HTML - “当前”将在现有窗口中打开表单,“新”将作为模式弹出窗口进行。
于 2013-07-10T23:05:29.547 回答