Hello Odooers, Odoogig and Odoo Lovers,
It’s Thursday.! And i’m coming with one more Odoo Technical Tutorial for you.
In this Odoo Techniacl Tutorial I would like to explain what is Domain in odoo and how to use it.
- As a Odoo programmer sometimes you need to find particular records based on condition from the model.f you do not know what is model in odoo then first refer this
- For Example, In model you want to search odoo developer who having a 8 year of experience . so at that time you have to use domain into search() search method of odoo.
- So it will return records which matches your search and latter you can use this records in further code
- Domain is a list of tuple, in which you can specify your search condition
Syntax of Domain
[('field_of_model', 'domain_operator', 'value_for_comparison')]
Example of Domain
[('name', '=', 'Mayur Maheshwari')]
- You can use other domain operator also which are:
- not like
- not ilike
- not in
- For using domain just go through below syntax an example
Syntax of using Domain
variable_name = self.env[‘model.name’].search(domain_here)
Example of using Domain filter
employee_ids = self.env['hr.employee'].search([('year_of_experience', '=', 8)])
Example of using Domain filter with and condition
domain = [('field_name','=',value),('field_name','=',value)]
Example of using Domain filter with or condition
domain = ['|', ('field_name','=',value),('field_name','=',value)]
Example of using Domain filter with multiple condition or and &
domain = ['|', ('field_name','=',value),('&',('field_name','!=',value),('field_name','=','value'))]
GET IN TOUCH.!
We’d Love to Hear from You! We are happy to answer any questions, you have regarding My Training.
Mail : firstname.lastname@example.org
Skype : mayur_maheshwari1
What’s app : +919924542042