Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
3169 มุมมอง

Hello,

I have this field :

switch_power = fields.Selection([('1','On'),('0','Off')],'Power')

And i have defined a button which change the value of "switch_power" according to this function :


@api.multi
def message_test(self):

if(self.switch_power=='1'):
self.switch_power='0'
raise osv.except_osv(('Button test!'), ('Le button est on'))

else:
self.switch_power='1'
raise osv.except_osv(('Button test!'), ('Le button est off'))

The problem is when i click in the button, The message is displayed, but the value of "switch_power" dosen't changed.


Any help please ?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

May be, Because of raising message, your method not execute properly, try to remove raise keyword line and then execute method.

อวตาร
ละทิ้ง

Ya, it's right.

ผู้เขียน

Ok i will try it

ผู้เขียน

It working for me

คำตอบที่ดีที่สุด

Hi,

Try to write the value to that field 

self.write({'switch_power' : '1'})

Thank you.

อวตาร
ละทิ้ง
ผู้เขียน

Hi Avinash, i have try that, but nothing happened.