Skip to Content
Menú
This question has been flagged
2 Respostes
9540 Vistes

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.

Avatar
Descartar

When should you use name_search method: https://goo.gl/7PHhPP

Best Answer

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!

Avatar
Descartar

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

Best Answer

you can extend by changing filter_domain:

<field name="name" string="Description" filter_domain="['|','|',('name','ilike',self),('ref','ilike',self),('desc','ilike',self)]"/>
Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de març 15
3984
1
de març 15
12019
2
d’oct. 24
12556
3
d’oct. 17
17020
1
de març 15
6298