跳至內容
選單
此問題已被標幟
1 回覆
2250 瀏覽次數

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.

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
6月 23
2600
1
11月 22
2861
2
4月 21
3205
0
8月 25
72
1
8月 25
1992