zoukankan      html  css  js  c++  java
  • odoo10 按钮点击时的弹窗提示确认消息

    odoo按钮点击时的弹窗提示确认消息

    场景:

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

    思路:

    在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的方法,大大简化了开发的难度!

     
  • 相关阅读:
    02-最简C语言程序
    Go学习笔记-GO编程语言手册
    Go学习笔记-Effective Go
    go学习笔记-语法
    机器学习-数据挖掘
    windows下jupyter notebook的安装及配置
    wpf学习笔记
    windows下安装mingW及控制台启用
    nginx
    MFC学习笔记
  • 原文地址:https://www.cnblogs.com/pywjh/p/12238145.html
Copyright © 2011-2022 走看看