首先,我想在OpenERP
中创建一个带有按钮的表单。单击该按钮后,该按钮将链接到 project.issue 表单
应该在按钮上写什么来执行这样的任务?
我在OpenERP
上使用了开发者模式。
答案 0 :(得分: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,您希望显示哪个视图... 希望它会对你有所帮助。
答案 1 :(得分: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,
}
答案 2 :(得分:0)
需要注意的一点是,在您返回的窗口操作中,您可以添加“目标”值。这与HTML类似 - “当前”将在现有窗口中打开表单,“new”将其作为模式弹出窗口。