İçereği Atla
Menü
This question has been flagged
1 Cevapla
4860 Görünümler

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
Vazgeç
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
Vazgeç
Üretici

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

Thanks!

Related Posts Cevaplar Görünümler Aktivite
1
Ağu 22
6877
2
Tem 22
3937
1
Tem 20
3325
2
Mar 18
15031
2
Haz 17
3504