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 | etc.
I am trying to setup a filter that will base itself off of the "Customer" field (partner_id) when creating or modifying a Sales Order. I am very new to OpenERP, so please pardon any obvious mistakes.
I made the following line in the search view to create the filter:
<filter string="Customers Items" domain="[('x_whereused','=',sale.view_order_form.partner_id)]" name="own_area_items"/>
x_whereused is a custom field I made in product.template which indicates which customers use what parts. I want the Add an Item - Search More view to have the above filter compare the partner_id in the newly made Sales Order with my custom field (x_whereused) and display if it matches. I get the following error currently when applying the filter.
"TypeError: context is undefined
Thanks very much for any assistance on this!
You can't use "sale.view_order_form.partner_id" in your filter, as the search view will not be able to understand it.
Also the filter needs to be part of the product lookup with in the sales order form.
Here is how you can add a filter to the products listing in a sales order:
And in your case the partner_id will be used as the id to filter with.
Add the following to the product_id field view defintion:
domain="[('x_whereused', '=', parent.partner_id)]"
You will find an example of the xpath section for doing this in the file "sale_stock_view.xml" (under the "sales" addon folder)
Look for the following section, which is the xpath section that needs to be modified:
<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="replace"
domain="[('x_whereused', '=', parent.partner_id)]" <-- Add this
You should of course put this this in your own addon that is used to override the exiting logic (hopefully you are doing that).
But if you just want to see it in action quickly, you can add that line above to the "sale_stock_view.xml" file, then under Settings->Apps find the "Sales Management" and do "Upgrade".
Now when you create an order and click on the product field it will be filtered by the partner_id. Of course, you can change that domain= to filter by other criteria also.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 12/31/14, 11:41 AM|
|Seen: 2113 times|
|Last updated: 5/24/15, 1:40 PM|