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.

0

Full list of search operators

By
Martin
on 3/17/14, 8:02 AM 4,531 views

According to the "Developer Book >> API" the search command is called like this :

 search([('arg1','=','value1')...], offset=0, limit=1000)

Where the second element in the tuple (arg1, arg2, .. ,argN: list of tuples specifying search criteria) is a . . .

search term operator ex: ilike, =, !=

Where can one find the definitive list of those search term operators ?

1

Ray Carnes

--Ray Carnes--
15717
| 9 7 9
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

Ray Carnes
On 3/18/14, 12:54 AM

A definitive list of search term operators can, in fact, be found in the source code (here) can't they?

Each tuple in the search domain needs to have 3 elements, in the form: ('field_name', 'operator', value), where:

  • field_name must be a valid name of field of the object model, possibly following many-to-one relationships using dot-notation, e.g 'street' or 'partner_id.country' are valid values.
  • operator must be a string with a valid comparison operator from this list: =, !=, >, >=, <, <=, like, ilike, in, not in, child_of, parent_left, parent_right The semantics of most of these operators are obvious. The child_of operator will look for records who are children or grand-children of a given record, according to the semantics of this model (i.e following the relationship field named by self._parent_name, by default parent_id.
  • value must be a valid value to compare with the values of field_name, depending on its type.

Domain criteria can be combined using 3 logical operators than can be added between tuples:

  • '&' (logical AND, default)
  • '|' (logical OR)
  • '!' (logical NOT)

These are prefix operators and the arity of the '&' and '|' operator is 2, while the arity of the '!' is just 1. Be very careful about this when you combine them the first time.

Here is an example of searching for Partners named ABC from Belgium and Germany whose language is not english ::

[('name','=','ABC'),'!',('language.code','=','en_US'),'|',
('country_id.code','=','be'),('country_id.code','=','de')]

The '&' is omitted as it is the default, and of course we could have used '!=' for the language, but what this domain really represents is::

[(name is 'ABC' AND (language is NOT english) AND (country is Belgium OR Germany))]

Thanks Ray. I asked where to find the list; I should really have asked where to find the full documentation, because not all the operators, or their effects, are obvious as you state. What, for example, is the difference between "like" and "ilike" ? Another: I got an error trying to use "ilike" on a record id, but the query worked when I used "=". I'm using XMLRPC where tracking down failures like the latter is really time consuming. Has no reference documentation, with example usage of each operator, been published anywhere?

Martin
on 3/18/14, 6:44 AM

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

0 follower(s)

Stats

Asked: 3/17/14, 8:02 AM
Seen: 4531 times
Last updated: 3/16/15, 8:10 AM