【发布时间】:2015-11-09 17:43:57
【问题描述】:
我是 OpenERP 新手,我在向导中放置了一个按钮。但是当我单击按钮时,向导会自动关闭而不调用该函数。 谁能解释一下,为什么?
【问题讨论】:
-
你是如何声明按钮的?
-
我将按钮声明为“对象”类型。
-
好的,然后检查我的答案
我是 OpenERP 新手,我在向导中放置了一个按钮。但是当我单击按钮时,向导会自动关闭而不调用该函数。 谁能解释一下,为什么?
【问题讨论】:
确保您具有属性type=object
<button name="do_compute" string="Compute" type="object" icon="gtk-apply" class="oe_highlight"/>
您将在本例中运行的方法的名称是do_compute。你必须返回这样的东西:
@api.multi
def do_compute(self):
self.ensure_one()
# operations
return {
'context': self.env.context,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'your.module.name',
'res_id': self.id,
'view_id': False,
'type': 'ir.actions.act_window',
'target': 'new',
}
【讨论】:
create 方法也会运行。