Odoo Help

Welcome!

This community 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.

1

Override name_search() but not affecting search in tree view

By
tim diamond
on 11/1/13, 3:17 PM 2,833 views

Hey Community!

I've overrided the name_search() method to help a client search products by other fields other than the defaults. However I found very weird functionality: While my override name_search() fires fine when, say, adding a product to a sales order (from the form drop down), it simply DOES NOT fire when I search from, say, the upper right hand box when I'm looking at a tree view of the products (the one that you use to access "advanced seach").

Would anyone have any idea why this is the case? If so, how can I use the functionality I have developed in my custom name_search in the regular search above tree view (without have to use advanced search)? The client wants to simply type in the search box, and seach by a field that is not the default.

1
Torsten Francke
On 11/28/13, 12:49 PM

you can extend by changing filter_domain:

<field name="name" string="Description" filter_domain="['|','|',('name','ilike',self),('ref','ilike',self),('desc','ilike',self)]"/>
1
JG
On 11/28/13, 9:15 AM

The search box on the tree view is reigned by the search form view, and not by the name_search method of the class. An example modified search view could have:

<search string="Description of the object">
    <field name="name" string="Description" filter_domain="['|',('name','ilike',self),('ref','ilike',self)]"/>
    <field name="another_property" />
</search>

The above search looks for objects that have either the name or the ref properties matching what's on the search field. The user can also select to look for "another_property" matches.

As a side note, there seems to be a maximum of two fields in the filter_domain section, I guess the functionality is limited to that at this point. Hope it helps!

You can add additional fields to the filter_domain by adding additional operators, ie ['|','|',('name','ilike',self),('name','ilike',self),('name','ilike',self)]

Daniel Kauffman
on 11/11/14, 9:30 PM

Your Answer

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/1/13, 3:17 PM
Seen: 2833 times
Last updated: 3/16/15, 8:10 AM