odoo自定义弹框提示错误

odoo自定义弹框提示错误

经常使用自带的提示错误,显示的都是Odoo Server Error,有些需求就是要自己定义提示框前面的文字。所以请往下看。

实现代码:

1.字段 py文件

 unit_price = fields.Float(string='单价')

2.视图 xml文件

 <field name="unit_price"/>

 

3.方法

  @api.onchange('unit_price')
    def compute_price(self):
        if self.unit_price < 0:
            return {
                'warning': {
                    'title': "检查到错误",
                    'message': "单价不能小于0",
                },
            }

效果图:

odoo自定义弹框提示错误