当用户按下“结帐”按钮时,我需要显示一个警告弹出按钮(只是一个确定/关闭按钮)
我避免使用raise Warning()
orraise ValidationError()
因为我想保留在现有页面上并简单地显示一个弹出警告。
您能否分享在 Odoo 13 中执行此操作的最简单方法?
单击继续结帐按钮称为jsonRpc
where call your json controller
with 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
}
});
谢谢