Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Many2many fields and Its widgets in Odoo

1,912 views

Published on

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.

Published in: Business
  • Be the first to comment

Many2many fields and Its widgets in Odoo

  1. 1. www.cybrosys.com Many2many fields and Its widgets in Odoo
  2. 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. 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. 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" />
  5. 5. Here is the view for this :
  6. 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. 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"/>
  8. 8. Here is the view for this :
  9. 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. 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"/>
  11. 11. Here is the view for this :
  12. 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.
  13. 13. Here is the view for this :
  14. 14. 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
  15. 15. Here is the view for this :
  16. 16. 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"]].
  17. 17. Example Code : .xml - <field name="field_name" widget="x2many_counter">
  18. 18. Thank You ! https://www.cybrosys.com/blog/many2many-fields-and-its-widgets-odoo

×