Odoo Help

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

I can't understand that s*** sorry! Help needed!

['&', '|',





('type', '=', 'normal')]

Mathieu Laflamme
on 3/16/17, 12:28 PM

This is part of Odoo 10 mrp_production_view.xml...

Mathieu Laflamme
on 3/16/17, 12:29 PM
Mohamed El Mokhtar
On 7/10/17, 8:10 AM

HI, thenk you for the explanation.

Can you help me, i want to do the filtering with a simple condition but using a value of the function type field

see the code

gerant_structure_id = fields.Integer('Structure id', compute='_getStructureIdForCurrentUser')

    def _getStructureIdForCurrentUser(self):
        structure_id = self.env['afya.structure.sante'].search([('gerant_id', '=', self.env.uid )]).id
        self.gerant_structure_id = structure_id

view ...

<record model="ir.actions.act_window" id="compte_wallet_list_action">
            <field name="name">Compte_Wallet</field>
            <field name="domain">[('structure_sante_id', '=',  gerant_structure_id)]</field>
            <field name="res_model">afya.compte.wallet</field>
            <field name="view_mode">tree</field>


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

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: 29792 times
Last updated: 7/10/17, 8:10 AM