Help

0

Boolean field set false is not involve in json post

Avatar
Agustin Ruiz Nattero

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
1 Answer
0
Avatar
Ravi Gadhia
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 

1 Comment
Avatar
Discard
Avatar
Agustin Ruiz Nattero
-

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

Thanks!