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

With the old api we could return a domain in the on change function, is this possible with the new api?

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

ok, its possible, but if the function has the decorator @api.one not works.

my error:

    @api.one
    @api.onchange('field_id')
     def onchange_field_id(self):
         relation_ids = [x.id for x in self.field_id.relation_ids]
         return {'domain':{'relation_id': [('id', 'in', relation_ids)]}}

but without @api.one works perfectly

    @api.onchange('field_id')
     def onchange_field_id(self):
         relation_ids = [x.id for x in self.field_id.relation_ids]
         return {'domain':{'relation_id': [('id', 'in', relation_ids)]}}

อวตาร
ละทิ้ง

Short update that it still works for V14/V15. Simply remove the @api.one there as this has been deprecated :-)

@Yenthe onchange that returns a domain is deprecated..

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

Yes, Its possible an onchange method can return three items (warning, domain, value)

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

You can also use @api.multi

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 17
6738
2
ส.ค. 25
251
2
ส.ค. 25
302
2
ส.ค. 25
465
0
ส.ค. 25
442