场景:

在单据页面操作工作流流程的时候,有时候会选择点击取消这份单据,但有时候会误点击,这时候最好是有一个弹窗消息提示一下你是否确认取消这样的消息

思路:

在button按钮上设置一个消息提示,后台设置提示的内容

实现:

在需要弹窗的按钮后面跟上这样一个属性:

<button name="action_cancel" icon="fa-close" string="Cancel" type="object" attrs="{'invisible':['|',('state','not in',('created','approved')),('is_creator','=',False)]}"
        class="oe_link" confirm_method="pre_cancel"/>

 

属性:confirm_method

后台对应一个属性名为pre_cancel的方法:

# 预取消确定
def pre_cancel(self):
    self.ensure_one()
    return _("Note: The document cannot be recovered if it has been cancelled, are you sure?")

 

这个方法只会在运行name=action_cancel之前,进行一个显示弹窗的动作,点击取消就无事发生,点击确认才会运行action_cancel的方法,大大简化了开发的难度!

 

相关文章:

  • 2022-12-23
  • 2021-10-29
  • 2022-01-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案