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

I am adding a dynamic domain filter in order_line of purchase order. I tried different methods and it doesn't work.

What is the correct way to make a dynamic domain filter?

 

อวตาร
ละทิ้ง

why do you need "dynamic domain filter" at PO line? If possible, provide us your scenario.

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

Hi,

In this code the purchase order line only shows the products of corresponding vendor.

class ResPartner(models.Model):
_inherit = 'purchase.order'

is_vendor_products = fields.Boolean(string='Vendor Products')

class PurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'

@api.onchange('product_id')
def vendor(self):
list1 = []
if self.order_id.is_vendor_products:
for product in self.env['product.product'].search([]):
for seller_ids in product.seller_ids:
if self.partner_id == seller_ids.name:
list1.append(product.id)
return {'domain': {'product_id': [('id', 'in', list1)]}}

Regards

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

Override "search" method. This is recurrent question, try to search it first (even though I also a little bit sceptic about search feature in this forum)

อวตาร
ละทิ้ง