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

I need to raise a warning while creating a sale record if the customer is outside of a state, but should still be able to continue or reject with the order creation.

Most raise exceptions would stop the execution.

How can I do it without stopping the create function?

Ảnh đại diện
Huỷ bỏ

Perhaps the OCA's web_notify module could be a solution? See https://github.com/OCA/web/tree/14.0/web_notify

@Yenthe: In this module, i see that they called message by bus.bus, but does this bus.bus need config some how to make it work? I've try to follow this module but not working for odoo 15, i guess i miss some config here.

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

You can leverage the alert class and conditionally show / hide a Warning at the top of the form, like we do when we detect the creation of a Contact with the same Tax ID as another:



You can use any domain to determine the visibility of the message, and can choose between info / warning / danger / success / primary decoration (the screenshot is a warning)


See https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/views/res_partner_views.xml#L147

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

Thanks, this would've worked if it was only warning. For my use case, user should be able to confirm or reject the creation based on the condition.

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

There is no exception that lets you do this. 


you need to create a transient model that will be displayed if customer is outside a state with button continue that the user clicks and continue the creation.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 6 21
6367
2
thg 5 21
13547
0
thg 7 22
2299
5
thg 5 25
7231
1
thg 10 24
22303