【问题标题】:openerp - wizard should not close on button clickopenerp - 向导不应在按钮单击时关闭
【发布时间】:2013-12-03 06:34:13
【问题描述】:

我在向导“更改标准价格(stock.change.standard.price)”上添加了一个按钮。可从 Products-> Procurement Tab -> "- update" 链接访问。

只要我单击该按钮向导就会关闭,尽管我不想关闭它。当我单击“应用”或“取消”时,它应该关闭。

代码如下:

按钮:

<button string="New Cost" name="get_price" type="object" class="oe_inline"/>

方法:

def get_price(self, cr, uid, ids, context=None):
    cost_price = 100
return {'new_price': cost_price, 'nodestroy': True}

我也将返回nodetroy,因为我读到它不会破坏向导。

我是不是做错了什么?

提前感谢。

【问题讨论】:

    标签: button openerp wizard destroy


    【解决方案1】:

    您应该像这样返回字典以重新打开向导,

    view_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','your wizard')])
    return {
        'type': 'ir.actions.act_window',
        'res_model': 'your wizard',
        'name': _('Your wizard Heading'),
        'res_id': ids[0],
        'view_type': 'form',
        'view_mode': 'form',
        'view_id': view_id,
        'target': 'new',
         'nodestroy': True,
         'context': context
            }
    

    【讨论】:

    • 我不想重新打开我只是不想关闭它。
    • @Pooja:它不会重新打开,除非您单击 X 按钮或特殊的“取消”按钮,否则它不会关闭。
    • @ashif:你不必计算 view_id 并通过它,没有它也可以工作。
    【解决方案2】:

    尝试像返回字典一样

        return {
            'name':_("wizard name"),
            'view_mode': 'form',
            'view_type': 'form',
            'res_model': 'model', # your current model
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'new',
            'context': {'default_fieldname': 'your value'}
        }
    

    这将重新打开向导。如果您想重新打开向导。

    【讨论】:

    • 您好,感谢您的快速回复。我已经尝试过了,但它会调用新向导。我想要相同的向导,因为我想继续使用该值。
    • 感谢解决方案,但问题是当我们单击更新时,此向导会弹出并且它已经带有默认成本价格。我的意思是我不想覆盖 default_get 并干扰常规流程。
    【解决方案3】:

    (Odoo 9/10) 最简单的做法是避免关闭向导:

    @api.multi
    def null_action(self):
        return {
            "type": "set_scrollTop",
        }
    

    由于该类型用于调用ActionManager类上的任何方法(javascript)

    比 "type": "ir.actions.do_nothing" 生成异常要好(这个属性不存在)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-18
      • 2014-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      相关资源
      最近更新 更多