I have added Vendor dropdown using custom field on Sale Order Line form, now there dispay all vendors but actually want to display product wise Vendors in dropdown
For Example
Product 1
- Vendor1
- Vendor2
- Vendor3
Product 2
- Vendor4
- Vendor5
So when we place order for product1 then show only Vendor 1,2 and 3 not all all 5 vendors, currently showing all 5 vendors,
can anyone help me regarding this how can we filter vendor product wise when we place new order.
Thanks a lot
you can use domain filtering on your many2one field or drop down field: http://learnopenerp.blogspot.com/2016/10/onchange-many2one-filed-in-odoo.html
Hello Everyone,
Thanks for your answers but can i know how can i add this code in custom field, I have followed below steps,
1) Added custom field x_vendors_id on sale order line using Settings -> Database Structure -> Models
2) Added below code in EditView on Sale Order for page.
<label for="x_vendors_id" string="Choose Vendor"/>
<div>
<field name="x_vendors_id" context="{'search_default_supplier':1, 'default_supplier':1, 'default_customer':0}" domain="[('supplier','=',True)]"/>
</div>
3) added custom code (your answers) on 1st step custom field page in "compute" field but not working.
can you please let me know it right way or do i need add it on another way?
Again Thank you much all of you.
NIKHIL KRISHNAN
api.onchange('product_id')
def onchange_project(self):
partner_ids = []
if self.product_id:
partner_ids = self.product_id.sellers_ids
return {'domain': {'tag_ids': [('id', 'in', partner_ids)]}}
Sudhir Aarya
@api.onchange('product_id')
def onchange_product(self):
if self.product_id:
return {'domain': {'x_vendors_id': [('id', 'in', [seller.name.id for seller in self.product_id.seller_ids])]}}`