odoo - 如何在 Odoo 13 网站中显示消息框
问题描述
当用户按下“结帐”按钮时,我需要显示一个警告弹出按钮(只是一个确定/关闭按钮)
我避免使用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
}
});
谢谢
推荐阅读
- postgresql - 尝试更新 Postgres 表中的 JSON 但出现未知错误
- c# - ASP.NET 中的 WindowsIdentity.Impersonate 随机“用于模拟的令牌无效 - 它不能被复制”
- laravel-5.8 - 如何修复 laravel 错误 5.8 哎呀!有一个错误。在脸书上分享时?
- javascript - Javascript树时间线
- python - XPATH 选择器无法选择 html 代码块
- node.js - 为什么 crontab 不执行我的节点脚本?
- python - 铸造复数值丢弃快速傅立叶算法的虚部
- r - 为 R 包生成可打印文档的标准选项是什么?
- svm - 在 Weka 3.8.3 中,设置 probaabilityEstimates true 或 false 时会得到不同的结果
- excel - 使用数据透视表值填充组合框