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

I wanna add a server validation before change(or create) data, if not passed, create a confirm dialog to let user choose still save or not.

The problem is that I don't know how to create a confirm dialog when in write method, it is possible to make dialog by returning action when click button, but this not be able for write method.

So I try to raise server Error to manually call `new ActionManager().do_action()` in crash_manager.js, another problem came, I cannot get the form view object to reload it.

It really drives me crazy, please help me or share some experience if you have done some similar work.

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

Please let me know if you find the solution, I am also having same problem

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

This will helpful

 
 

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

I've built a module to help for this case, please check it out:

https://apps.odoo.com/apps/modules/13.0/web_confirm_on_save


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

By using confirm tag in xml . You can do it . No need to write a method in python.


e.g.

  <button name="cancel_voucher" string="Cancel" type="object" states="posted" confirm="Are you sure you want to cancel this receipt?"/>

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

Actually, I need to do a validation before confirm dialog. I have done it with overwrite save button code.

Then you have to use python raise function in onchange method . So that you will get the validation before confirm message.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 24
6042
3
thg 8 24
6887
4
thg 7 24
41201
5
thg 4 23
98943
3
thg 11 22
4324