Hello,
In a new sale order I want to filter only products that have been previously ordered by the selected partner.
Any suggestions ?
Working on Odoo Community 13.
Thank you!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello,
In a new sale order I want to filter only products that have been previously ordered by the selected partner.
Any suggestions ?
Working on Odoo Community 13.
Thank you!
Hi,
your query is: When you create a SO, list of possible products to be selected must only be the previous ones that were purchased by the selected client.
In this case:
1- Onchange on partner_id.
2- If partner_id is changed, then:
A. Get all products in previous customer's Orders : product_ids = self.partner_id.sale_order_ids.mapped('order_line.product_id')
B. add domain to product_id in order line.
In sale.order.line,the function should look like this:
@api.onchange('order_partner_id')
def onchange_order_partner_id(self):
domain = []
if self.order_partner_id != self._origin.order_partner_id:
if self.product_id:
self.product_id = False ( you may want this to make product_id empty )
product_ids =self.order_partner_id.sale_order_ids.mapped('order_line.product_id')
domain += [('id', 'in', product_ids.ids)]
return {'domain':{'product_id': domain}}
i hope this helps.
Create an account today to enjoy exclusive features and engage with our awesome community!
PrijaviRelated Posts | Odgovori | Prikazi | Aktivnost | |
---|---|---|---|---|
|
2
jun. 23
|
3546 | ||
|
1
jan. 25
|
11189 | ||
|
3
feb. 16
|
8723 | ||
|
3
apr. 20
|
6381 | ||
|
1
apr. 18
|
8193 |