Skip to Content
Menu
This question has been flagged

I define a Boolean field with a default value as true, as bellow:

############################################
    bool1 = fields.Boolean('Cant Create as False', default=True)
    bool2 = fields.Boolean('Check to set False the other')
    @api.onchange("bool2")    
    def change_bool2(self):
        if self.bool2 == True:
            self.bool1 = False
###############################3#################

When the user check bool2, the bool1 is set false, as we can expect. 
But, when the user save the change, bool1 return to True again.
With the browser developer tool, in the networking monitor you can see that in the params of the records, it is not include the value bool1: false.

Is there some param that I dismiss to get involve the bool1 in te json sended in the create/write post?

, Best Regards,
Agustín


Avatar
Discard
Best Answer

I think you set bool1 fields as readonly. in this case,  client will not send it's value to server even though it's changed.
if this is the case then add force_save="1" on bool1 XML definition it will force the client to send data 

Note: if I remember correctly force_save introduce in V11 

Avatar
Discard
Author

It was not an readonly field, but your solution work fine.

Thanks!

Related Posts Replies Views Activity
1
Aug 22
6317
2
Jul 22
3068
1
Jul 20
2763
2
Mar 18
14277
2
Jun 17
3008