Odoo Help


Override name_search() but not affecting search in tree view

tim diamond
on 11/1/13, 3:17 PM 4,091 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.

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" />

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
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)]"/>

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


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