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

In res.config .settings I have a checkbox and a many2one field. When I click on the checkbox, it shows the many2one field. I then select a value for many2one and save. This value is visible in the database.
But when I deselect the checkbox and leave the value in many2one this value from the many2one field is saved in the database.
I would like the value from many2one not to be saved in the database if the checkbox is unchecked.

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

Hi Ewdy,

Define an onchange function for your checkbox(boolean field). In that if the check box is not selected, you have to reset the value in the many2one field to False.

Try this:

@api.onchange('your_check_box_field')
def onchange_your_check_box_field(self):
if not self.your_check_box_field:
self.many2one_field = False


Thank you

Ả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 23
2600
1
thg 11 22
2861
2
thg 4 21
3201
0
thg 8 25
58
1
thg 8 25
1990