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

Hello,

I have defined 2 fields :

switch_power = fields.Selection([('1','On'),('0','Off')],'Power')
switch_power_bool = fields.Char(string='Switch_power_bool', required=False)

And i have defined a function which modify the "switch_power_pool" according the "switch_power"

@api.onchange('switch_power')
@api.multi
def change_switch_bool(self):

pack = self.env['affichage2.pack_stock'].search([('id', '=', self.pack_id.id)])
tab=[0]*(pack.switch_number)
xx = ''.join([str(x) for x in tab])
tab[self.pin_switch]=self.switch_power
b = ''.join([str(x) for x in tab])
self.switch_power_bool=b

My problem is that the "swith_power_bool " didn't changed.

Any help please ? Thank you 



Avatar
Discard
Best Answer

Hi Zakaria,

Please try to remove  this from your code,

@api.multi

Try this one

@api.onchange('switch_power')
def change_switch_bool(self):

pack = self.env['affichage2.pack_stock'].search([('id', '=', self.pack_id.id)])
tab=[0]*(pack.switch_number)
xx = ''.join([str(x) for x in tab])
tab[self.pin_switch]=self.switch_power
b = ''.join([str(x) for x in tab])
self.switch_power_bool=b


I hope this will help you. 


Rgds,

Anil R.K.

 

Avatar
Discard