I am using V14cI have created a selection field on my sales form that has the same values as a selection field on my product form. Is there a way to limit the selection of products on the order lines to only display items that match the value of the selection field on the sales form?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hello Doug,
To do this you need to change the domain of the product_id in the sale.order.line tree view on the sale.order form. Here is an example which only gets products where the product "default_code" is equal to the sales order's "client_order_ref".
You would just need to change the field "default_code" to your field name on the product and change "client_order_ref" to the field on the sales order.
You need to create an inherited view which can either be done using debug more or creating your own module and installing, code:
<xpath expr="//field[@name='order_line']/tree[1]/field[@name='product_id']" position="attributes">
<attribute name="domain">
[('default_code', '=', parent.client_order_ref),
('sale_ok', '=', True),
'|',
('company_id', '=', False),
('company_id', '=', parent.company_id)]
</attribute>
</xpath>
The bit in bold is what I have added the rest is the standard domain used in Odoo, it is best to keep this in.
Also: you mention that yours is a selection field, if it is a Many2one you may need to add .id on the end of the right hand part of the expression.
I hope this helps.
Thanks,
Thanks this worked perfectly.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up