List of search operators in Odoo

Searching can’t be completed without search operators. They will be helpful when using with domain attributes.

Search operators

Search domain can contain zero or multiple tuples. Each tuple needs to have 3 elements, in the form of ('field_name', 'operator', value).

['|', '|', ('default_code', 'ilike', self), ('name', 'ilike', self), ('barcode', 'ilike', self)]

In this part, we will only need to know all possible value of 'operator‘. This will help us explain correctly our search intent and make Odoo return the correct data set.

List of available term operators:

'=', '!=', '<=', '<', '>', '>=', '=?', '=like', '=ilike', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in','child_of', 'parent_of'

Logical operators 

Tuples in the domain can be combined using logical operators. There are 3 of them.

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

The AND operator is used by default if there is no set operator.

Let’s go over some examples to see how their logics.

[('default_code', 'ilike', keyword), ('name', 'ilike', keyword)]
=> ('default_code', 'ilike', keyword) AND ('name', 'ilike', keyword)
['|', ('default_code', 'ilike', keyword), ('name', 'ilike', keyword)]
=> ('default_code', 'ilike', keyword) OR ('name', 'ilike', keyword)

=> (name is 'ABC' AND (language is NOT english) AND (country is Belgium OR Germany))

Leave a Comment

Your email address will not be published. Required fields are marked *