As all data manipulated with Odoo is stored in objects, they are exposed to the user through “Views”, Views define the way the records of a model are displayed. They are one of the essential elements that define the data records declaring the module interface components, in their turn, views describe how each object (type of resource) is displayed. More precisely, for each object, we can define one (or several) view(s) to describe which fields should be drawn on the web page and how.

There are 9 types of views:

  • List : or tree view, exposes a list of records with chosen fields to be displayed among others. The root element of list views is <tree>.
  • Form : Form views are used to display the data from a single record. Their root element is <form>.
  • Graphs : The graph view is used to visualize aggregations over a number of records or record groups. Its root element is <graph>.
  • Kanban : The kanban view is a kanban board visualisation: it displays records as “cards”, halfway between a list view and a non-editable form view. Records may be grouped in columns for use in workflow visualisation or manipulation (e.g. tasks or work-progress management), or ungrouped (used simply to visualize records). The root element of the Kanban view is <kanban>.
  • Calendar : Calendar views display records as events in a daily, weekly or monthly calendar. Their root element is <calendar>
  • Gantt : Gantt views appropriately display Gantt charts (for scheduling). The root element of gantt views is <gantt/>.
  • Diagram : The diagram view can be used to display directed graphs of records. The root element is <diagram>.
  • Search : Search views are a break from previous view types in that they don’t display content: although they apply to a specific model, they are used to filter other view’s content (generally aggregated views e.g. Lists or Graphs). Beyond that difference in use case, they are defined the same way. The root element of search views is <search>.
  • Qweb : QWeb views are standard QWeb templates inside a view’s arch. Qweb views are composed of regular XML mixed with QWeb  Template Engine directives.They don’t have a specific root element.

Views can either be requested generically via their type (e.g. a list of invoices) or specifically via their record id defined in XML description files. For generic requests, the view with the correct type and the lowest priority will be used since the lowest-priority view of each type is the default view for that type.
Odoo user interface is dynamic, which means that it is not described “statically” by some Python or HTML code, but dynamically built from loading XML records’ description. Every model (resource type) uses its own interface, which means, its own List view, Form or Calendar views if any, A notable characteristic of these views, is that they can be edited at any moment, even during the module execution. After a modification to a displayed view has occurred, you simply need to upgrade the module to which corresponds that ‘view’ and re-open it for the changes to appear.

View’s field and field’s widget :

On the one hand, a view’s field : defines a column where the corresponding object’s field should be displayed for each record. On the other hand, a field widget, in general, is Odoo view’s representation of an HTML input element on the web page. The field widget handles the rendering of the HTML, and the extraction of data from a recordset or record that corresponds to the object field.

There are two broad categories of fields in Odoo 8 : “Basic” fields which are atomic values stored directly in the model’s table and “Relational” fields linking records (of the same model or of different models) that are used to represent relations between objects.

Basic fields

  • class openerp.fields.Char(string=None, **kwargs)
  • class openerp.fields.Boolean(string=None, **kwargs)
  • class openerp.fields.Integer(string=None, **kwargs)
  • class openerp.fields.Float(string=None, digits=None, **kwargs)
  • class openerp.fields.Text(string=None, **kwargs)
  • class openerp.fields.Selection(selection=None, string=None, **kwargs)
  • class openerp.fields.Html(string=None, **kwargs)
  • class openerp.fields.Date(string=None, **kwargs)
  • class openerp.fields.Datetime(string=None, **kwargs)

Relational fields

  • class openerp.fields.Many2one(comodel_name=None, string=None, **kwargs)
  • class openerp.fields.One2many(comodel_name=None, inverse_name=None, string=None, **kwargs)
  • class openerp.fields.Many2many(comodel_name=None, relation=None, column1=None, column2=None, string=None, **kwargs)
  • class openerp.fields.Reference(selection=None, string=None, **kwargs)

Whenever you specify a field on a view record definition, Odoo will use a default widget that is appropriate to the type of data that is to be displayed. However, if you want to use a different widget for a field, you can just use the widget argument on the field definition.

In conclusion, widgets do not need to be assigned to view’s fields, until you want a different HTML rendering and representation for it.

To find which widget is used on which field, see our next article. we will present you a brief tutorial on how to use both default selection widget and priority widget for Selection field type.