Odoo Help



| 7 8 8
Thiruvananthapuram, India

Working as an Senior ODOO developer. http://in.linkedin.com/pub/remya-r/69/a23/298

On 7/24/14, 1:53 AM

Explaination of OpenERP domain filter with simple example:

Consider the following fields in XML view.

<field name="field1"/>

<field name="field2"/>

<field name="field3"/>


Single condition:


Simple condition in programming:                           

if field1 = 10

In OpenERP domain filter, it will be written as:

syntax : Each tuple in the domain has three fields ->  ('field_name', 'operator', value)

field_name : a valid name of field of the object model or in the database table

operator : valid operators are =, !=, >, >=, <, <=, like, ilike, in, not in, child_of, parent_left, parent_right (openerp/osv/expression.py)

value : a valid value to compare with the values of field_name, depending on its type.

ie, domain = [('field1','=',10)] # where field1 should be a field in the model and 10 will be the value

or domain = [('field1','=',field2)] # where field1 and field2 should be the fields in the model

Condition AND

Simple condition in programming:    

if field1 = 5 and field2 = 10

In OpenERP domain filter, it will be written as:

ie, domain = [('field1','=',5),('field2','=',10)]

or domain = [('field1','=',field3),('field1','=',field3)]

Note : Note that if you don't specify any condition at the beginning and condition will be applied.

Condition OR

Simple condition in programming:    

if field1 = 5 or field2 = 10

In OpenERP domain filter, it will be written as:

ie, domain = ['|', ('field1','=',5),('field2','=',10)]

or domain = ['|', ('field1','=',field3),('field1','=',field3)]


Multiple Condition

Simple condition in programming:  

if field1 = 5 or (field2 ! = 10 and field3 = 12)

In OpenERP domain filter, it will be written as:

domain = ['|',('field1','=',5),('&',('field2','!=',10),('field3','=','12'))]


Also this post from Vivek will be helpful to all. Cheers!!

Hi there, thank you for the explanation. Can you help me to understand this domain filter for contracts: [('employee_id.user_id', 'in', [usr.id for usr in user.user_ids])] Thank you in advance.

on 9/6/15, 9:15 PM
Peregrin Tuk
On 5/13/15, 2:28 PM

I'm looking for some insight about a tiny detail:

Regarding this definition

    domain = ['|',('field1','=',5),('&',('field2','!=',10),('field3','=','12'))]

what's/why the difference between the lack of quotes like in 5 or 10 values and and the quoted one like in '12' ?


The coder may declared the fields3 as string fields and other 2 fields as integer

Karthik Arumugam
on 7/13/15, 3:59 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 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

1 follower(s)


Asked: 7/24/14, 1:53 AM
Seen: 23587 times
Last updated: 10/19/16, 5:08 AM