In this article you will learn about search operators used in Odoo search and domain filters. Each tuple in the search domain needs to have three elements, in the form of
Comparison Operators in Odoo
('field_name', 'operator', value)
where:
Element | Description |
---|---|
field_name | 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 | 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 | value must be a valid value to compare with the values of field_name, depending on its type. |
Now I am going to show you the example of usage of these operators.
Operator | Usage | Description |
---|---|---|
like | [('input', 'like', 'open')] | Returns case sensitive (wildcards - '%open%'). O/p: open, opensource, openerp, Odooopenerp |
not like | [('input', 'not like', 'open')] | Returns results not matched with case sensitive (wildcards - '%open%'). O/p: Openerp, Opensource, Open, Odoo, odoo, OdooOpenerp |
=like | [('name', '=like', 'open')] | Returns exact (= 'open') case sensitive search. O/p: open |
ilike | [('name', 'ilike', 'open')] | Returns exact case insensitive (wildcards - '%open%'). O/p: Openerp, openerp, Opensource, opensource, Open, open, Odooopenerp, OdooOpenerp |
not like | [('name', 'not ilike', 'open')] | Returns results not matched with exact case insensitive (wildcards - '%open%'). O/p: Odoo, odoo |
=ilike | [('name', '=ilike', 'open')] | Returns exact (= 'open' or 'Open') case insensitive. O/p: Open, open |
in | [('value1', 'in', ['value1', 'value2'])] | in operator will check the value1 is present or not in list of right term |
not in | [('value1', 'not in', ['value2'])] | not in operator will check the value1 is not present in list of right term |
= | [('input', '=', 'open')] | Returns case sensitive (exact match - 'open'). O/p: open |
!= | [('input', '!=', 'open')] | Returns results not matched with given input (other than - 'open'). O/p: other than open records |
> | [('input', '>', '10')] | Returns results greater than given input (other value greater than - '10'). O/p: 11, 12, 13 |
>= | [('input', '>=', '10')] | Returns results greater or equal of given input. O/p: 10, 11, 12, 13 |
< | [('input', '<', '10')] | Returns results less than given input (other value less than - '10'). O/p: 9, 8, 7 |
<= | [('input', '<=', '10')] | Returns results less or equal of given input. O/p: 10, 9, 8, 7 |
0 Comments