跳至内容
菜单
此问题已终结
1 回复
2228 查看

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
2597
1
11月 22
2860
2
4月 21
3187
1
8月 25
1925
1
7月 25
2524