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

Hello All,

i want to set domain on Many2one field based on Many2one's sub Many2many field. 

i have one Many2one field(A) and this field has Many2many field, and i have another Many2one field(B), i want to filter field B record based on field A's sub many2many field's record.

field B is of model(a.a) and A's many2many sub field model is a.a so how to do this.


 

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

try this

@api.onchange('your_m2m_field')
def _get_product_domain(self):
self.ensure_one()
self.product_id = False
products = self.your_m2m_field.mapped('product_id').mapped('id') #you rewrite this line as per your requirement
if products:
return {'domain':{'product_id':[('id', 'in', products)]}}
else:
return {'domain':{'product_id':[('id', 'in', [])]}}
อวตาร
ละทิ้ง

Thanks, Rakesh,
it's really useful for me.

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ค. 24
7863
Domain with inherited field แก้ไขแล้ว
1
ต.ค. 22
3827
8
ก.พ. 17
8370
0
ม.ค. 17
5878
2
ก.พ. 24
12580