Many2many widget is a datatype in python that helps to build odoo
In this presentation we will talk about the widgets that support the many2many field
This helps odoo developers to set their preferred view for a many2many field.
2. • Odoo is an open source business software that support wide range of
business domains.
• Many2many widget is a datatype in python that helps to build odoo
• In this presentation we will talk about the widgets that support the
many2many field
• This helps odoo developers to set their preferred view for a
many2many field.
INTRODUCTION
3. There are some many2many widgets in odoo as follows:
- many2many widget (default)
- many2many_tags widget
- many2many_checkboxes widget
- many2many_kanban widget
- many2many_binary widget
- x2many_counter widget
4. 1. many2many Widget (default)
• This widget is used in default cases
• Many2many widget generates a list view of the related model and the objects in the model
Example Code :
.py - field_name =fields.Many2many('res.partner',string="many2many_default")
.xml - <field name="field_name" />
6. We can add options like :
.xml - <field name="field_name" options="{'no_create': True}"/>
no_create : This will remove “Create” button . That is to model is we map the
objects from the model but creation of data not possible
7. 2. many2many_tags widget
This widget allows multiple selection of items. This method is implemented in project
module for adding “tags”.
Example Code :
.py - field_name = fields.Many2many('res.partner', string="many2many_tags")
.xml - <field name="field_name" widget="many2many_tags"/>
9. We can add options like :
.xml - <field name="field_name"
widget="many2many_tags"
options="{'no_create_edit': True}"/>
no_create_edit : Removes the “Create “agro” ” option.
no_quick_create : Removes the “Create and Edit” option.
10. 3. many2many_checkboxes widget
• This type of widget display a list of checkboxes
• Many2many_checkboxes display single checkbox for each record existing in the model
depending on the relation and domain.
• Checked records will be added to the field.
Example Code :
.py - field_name = fields.Many2many('res.partner',
string="many2many_checkboxes")
.xml - <field name="field_name" widget="many2many_checkboxes"/>
12. 4. many2many_kanban widget
• In many2many_kanban widget related objects are viewed in Kanban View
• Depending on the Kanban view defined , look and impact of the widget
changes accordingly
• This is more comfortable because it can vary its look based on customer
requirement by changing Kanban view definition.
15. 5. many2many_binary widget
• Many2many_binary is used for attachment purpose
• Attach a file in email are examples of this
• User can upload as many files and attach this to a model
• This widget works exclusively on many2many fields associated with
the ir.attachment model
18. 6. x2many_counter widge
• A simple, read only widget displaying a link with an information about the number of related
items.
• The link’s target view can be configured with the views option.
• Also useful with one2many fields.
• The views to display in the act window action must be a list of tuple whose first element is
the id of the view to display (or False to take the default one) and the second element is the
type of the view.
• Defaults to [[false, "tree"], [false, "form"]].