Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
15112 Lượt xem

something like this:

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

warning.UserError('blablabla');

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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);

Ảnh đại diện
Huỷ bỏ
Tác giả

Hi Jigar, thanks for the comprehensive answer!

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

Câu trả lời hay nhất

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"});
​}
}


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I can see the following error:

Uncaught Javascript Error > this. do_warn  is not a function


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 21
15802
1
thg 4 21
4468
1
thg 4 20
3126
0
thg 3 20
2269
1
thg 2 20
3985