Skip to Content
Menu
This question has been flagged
1 Reply
2560 Views

I am using Odoo13. I have some checkbox (boolean fields).

x= fields.Boolean(string='x')

y= fields.Boolean(string='y')
z= fields.Boolean(string='z')

Now I need to create data but I need minimum 1 boolean fields required. 



Avatar
Discard
Author

Thanks a lot. It works.

Best Answer

Inside the create function of your model.

@api.model 

def create(self, vals): 

    if vals['x'] == False and vals['y'] == False and vals['z'] == False: 

            raise UserError("Minimum one required.") 

    res = super(OpAdmission, self).create(vals)

    return res

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 19
12363
4
May 24
10062
1
Apr 24
1560
0
Nov 23
523
1
Sep 23
560