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

Hello,

​I'm currently  working on a custom module in wich i'd like to modify 2 domains if an other is change. It look like this:

​@api.onchange('field_1')    
def onchange_partner_id(self):       
​for rec in self:
            ​return {'domain': {'field_2': [('parent_id', '=', rec.field_1.id)]}},{'field_3': [('parent_id', '=', rec.field_1.id)]} 

If it's not possible, please tell me if they're is an other way to do so, otherwise thank you for your answers !

Have a nice day,

Ewen JEZEQUEL

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

Hi,

The code you provided contains a syntax error where you have two separate dictionary objects.

Here is the corrected code:


@api.onchange('field_1')

def onchange_partner_id(self):

    for rec in self:

        return {'domain': {'field_2': [('parent_id', '=', rec.field_1.id)],

                           'field_3': [('parent_id', '=', rec.field_1.id)]}}


Hope it helps

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

Hi, 

You can watch following video for this:

https://youtu.be/ezH3ql5Dmx4

Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 15
5002
when i use @api.model? แก้ไขแล้ว
3
พ.ย. 24
17844
1
พ.ย. 22
3128
2
ธ.ค. 19
8175
1
มี.ค. 19
3596