1

当用户按下“结帐”按钮时,我需要显示一个警告弹出按钮(只是一个确定/关闭按钮)在此处输入图像描述

我避免使用raise Warning()orraise ValidationError()因为我想保留在现有页面上并简单地显示一个弹出警告。

您能否分享在 Odoo 13 中执行此操作的最简单方法?

4

1 回答 1

2

单击继续结帐按钮称为jsonRpcwhere call your json controllerwith that add your custom logic on the controller and return that and on the js check with your condition and raise your Dialog-Box Like this,On Js:

var Dialog = require('web.Dialog');
ajax.jsonRpc("/custom/url", 'call', {}).then(function(data) {
    if (data) {
        var dialog = new Dialog(this, {
            size: 'medium',
            $content: _t("<div style='font-size:14px;font-family:Helvetica, Arial, sans-serif;'>Error.</div>"),
            buttons: [{
                text: _t('Ok'),
                classes: "btn-primary",
                close: true
            }],
        }).open();
    } else {
        // odoo logic
   }
});

谢谢

于 2020-04-03T11:10:55.523 回答