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
http://_________/web/js.web.assets_backend/7b7a275:3778"
Thanks very much for any assistance on this!
Hi Kyle, you should change your "answer" below to a comment to my answer. Click the "Convert as comment" to do that. You may have to also copy-paste it as a comment to my answer. Also, click the grey circled checkmark on my answer to "accept" it.
And I'm checking out how to answer your further question...
Thanks! I'm definitely going to try that out. One question I have is in the case that I wanted the user to be able (if they wanted) to go through the other listings that are not matching the x_whereused field (say the item is not in the list and the sales man wants to check for something not necessarily associated with that customer), would they be able to do this with the above code in place? Please excuse me if I'm mis-understanding, but from what I can tell, the code you gave will filter the results regardless of filters being applied in the search window itself. My idea came up from observing the "My" filter in th Draft Quotations view, that shows your own drafts, and then if you remove it, it shows everyone's. Thanks and Happy New Year!
Hello. I follow what you are asking for. Unfortunately I've not found out how to do that. The domain puts a filter there, which is not shown to the user. Normally you use default_search_(field) to set a default that is shown as a search filter to the user. But that is not made for doing a lookup on a many2one within a form. So, at this point it is probably best to work out the other parts of your system and then come back to this when you have a better understanding of the various capabilities.
Well, been a long time coming but I finally ended up revisiting this and got your code implemented in a module. I decided to ditch the optional part of seeing another customers parts as that can be done in the product menu, doesn't need to done in the sales order. The final code I ended up using is: sale.view.order.form.inherit sale.order <xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="attributes"> [('whereused','=',parent.partner_id)]