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

In my form view I have added a simple button of type object-

<button name="select_call_api" string="select" type="object"/>

And in my python model file I have added the function call-

def select_call_api(self):
print("select_call_api called")


But on button click it's by default doing form validation. Like if there are any mandatory fields and
they are not filled, then it's throwing "The following fields are invalid:" Error.
How do I disable or skip the form validation?

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

Hello,


I am not sure this is still needed but I have found a way.


This has been tested with Odoo 10.


I have found that using the `special` attribute allowed you to bypass validation.

Also, no validation is made on the value of the special attribute and only the value `cancel` is used to cancel.


Define your button this way:


                            name="abort" 
string="Abort"
type="object"
class="btn btn-default"
special="[ANYTHING BUT NOT cancel]"


and it will disable form validation, will not trigger `create` or `write` method but will trigger the method set as name (abort in this case).

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

There is no way because odoo framework architecture designed that way. when you click on the button framework try to create a new record and it will check all the required fields.

A workaround is checking form validation on fields onchange it didn't require to create a record first. however, all the fields value get on the server-side.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
Non-dict expression Đã xử lý
2
thg 7 22
2906
0
thg 10 19
3143
0
thg 3 24
1141
2
thg 1 22
4679
2
thg 1 20
5777