Odoo Help


Search for a name "starting with"...

Antoine Morit
on 6/18/14, 3:54 AM 3,066 views

When you use a search, for example in the partner view, you get all names containing the word searched.

example for a search "te" :

ABC Company Limited, Tested One, View Technologies,  etc...

Is there a way to get only the names starting with the word searched ?

For the same example, for a search "te", we will only get :

Tested One

Thanks for help

Bogus answer. i accidentally clicked on "Convert to answer" on a comment (that wasn't even mine!) and I can't find a way to delete this answer.

MONK Software, Leonardo Donelli
on 6/18/14, 5:01 AM

In search box, click on little down arrow and open full search menu. Select advanced search, choice name beginnig with Antonio Maria Vigliotti

Antonio M. Vigliotti
on 6/18/14, 5:56 AM

Sorry, Leonardo is right. There is no option "beginning with" in advanced search

Antonio M. Vigliotti
on 6/18/14, 5:57 AM
René Schuster
On 6/18/14, 4:55 AM

Let's stick to your example: res.partner view

The search view has this field:

<field name="name" filter_domain="['|','|',('name','ilike',self),('parent_id','ilike',self),('ref','=',self)]"></field>

Let's focus on the first search tuple: ('name','ilike',self)

That filters all partners, that has the entered search name as part of the their name. (Note that ilike operator is case-insensitive (ilike is postgresql specific), while like is case-sensitive). SQL: name ILIKE '%self%'

What you want to perform is the query: name ILIKE 'self%'.

The like and ilike operators in OpenERP automatically add the wildcards arround the search term. To avoid that, you should use =like and =ilike operators. You then need to add the wildcard manually (otherwise it will search for the exact term), so I would guess you should change the search tuple to:


I'm not sure you can add strings this way, but give it a try. Also change the other search tuples accordingly.


EDIT (since the reactions on this answer are wrongly brisk):

I've tested the mentioned search domain (name,'=ilike',self+'%') and it doesn't work.

What did work was (name,'=ilike',self) and searching for 'te%'. But that's not very userfriendly.

So the derived question from the OPs question is: How to automatically add the wildcard to the search term?


Best regards.

Ivan Elizaryev
On 6/19/14, 2:49 AM

I have tested René Schuster's solution on latest version openerp and it works:

<field name="name" filter_domain="['|','|',('name','=ilike',self+'%'),('parent_id','=ilike',self+'%'),('ref','=',self)]"></field>

it sends correct request ang get correct result



It returns only contacts starting with "a".

So, the solution is to modify base.view_res_partner_filter view with filter_domain above



You can use '=like' or '=ilike' operator in domain for starting with comparision.

This is since v5, glad to share I worked for expression.py.


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

6 follower(s)


Asked: 6/18/14, 3:54 AM
Seen: 3066 times
Last updated: 3/24/17, 8:07 AM