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.
How to create many2many field in Odoo
Read More: How to Create Model and Fields 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.
Read More: Apply domain on many2one field in Odoo
2 Comments
So simple, so nice!
ReplyDeleteCool bro!
thanks :)
Delete