Search Here

Add Domain Filter On Many2many Field in Odoo

In this article I will show you how to create a many2many field in Odoo. I will also show you guys how to filter many2many field using domain. You can also learn how to set default value on many2many field.



Set domain on many2many field in odoo

How to create many2many field in Odoo

your_many2many_field = fields.Many2many('model.name','your_many2many_table_name', 'column_1','columns_2', string="My many2many Field")

Code Description

  • "model.name" is the name of that model which you want to select/show as many2many.
  • "your_many2many_table_name" is the name of third table, you can write any name as you want.
  • "column_1" will be parent table reference or id.
  • "columns_2" will be many2many table reference or id.

Add domain on many2many field in Odoo.


Now we will add domain on many2many field.


Code Description


In above code we have added "domain=_add_domain" and create a function that will return our desired ids which we want to load/filter on many2many field.


Load default value on many2many field.



How can i select only the users belongs to a particular group in a many2many field


Post a Comment

2 Comments