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

Hi, i would like to put 2 on_changes functions in the same field, and i don't know how to define it in the xml view. Thanks.

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

If you need them for math computation try this



@api.onchange('field1', field2')

def onchange_name_of_onchange(self):

if self.field1 or self.field2:

self.fieldresult = self.field1 * self.field2


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

+1 Odoo Honduras, thanks

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

you can't do it using xml, you need to do it using the new api style for onchange, like:

@api.onchange('marital_status')

def onchange_m(self):

self.sex = 'm'

@api.onchange('marital_status')

def onchange_f(self):

self.sex = 'f'

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

There is no way to do it, but there is no need to do 2 onchanges, you can do it once, and return more values, it depends on what you are trying to do.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ต.ค. 23
2050
"Wrong value for %s: %r" % (self, value) แก้ไขแล้ว
2
ต.ค. 23
2295
2
ส.ค. 23
4306
4
ส.ค. 23
20630
3
ต.ค. 22
11086