Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
15135 มุมมอง

something like this:

var warning = require('web.warinig');

warning.UserError('blablabla');

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello mark,

You can use do_warn or do_notify function to create notification on top-right Odoo screen.
this.do_warn(title, message, sticky, className);
Same params for do_notify.

If you want display warning in popup(dialog) then you can use alert dialog.
var Dialog = require('web.Dialog');
Dialog.alert(this, message, options);

อวตาร
ละทิ้ง
ผู้เขียน

Hi Jigar, thanks for the comprehensive answer!

what is i wanted to send these notifications from python code ?

คำตอบที่ดีที่สุด

for odoo 16

import { useService } from "@web/core/utils/hooks";

export class TstMsg extends Component {
​setup() {this.notification = useService("notification");
​ this.notification.add("Test msg", {title: "TEST", type: "danger"});
​}
}


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I can see the following error:

Uncaught Javascript Error > this. do_warn  is not a function


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
this.do_notify("Success", "Your Message has been send successfully...");

I can see the following error:

Uncaught Javascript Error > this.do_notify is not a function

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 21
15815
1
เม.ย. 21
4492
1
เม.ย. 20
3135
0
มี.ค. 20
2274
Creation of DOM from XML แก้ไขแล้ว
1
ก.พ. 20
3992