How to create a List, Graph and Pivot views in Odoo?

Hello everyone. Now, we’ll have a quick look at how to define list (tree), graph and pivot views. List views are used when we work in list mode in order to visualize several resources at once. These views are simpler than the form views and have less options.
Here we have a model named Marks which has a Many2one fields called ‘student_id’ ‘course_id’ and four float fields ‘exam1’ ‘exam2’ ‘extrat’ and ‘average’.
The Mark model has associated a Tree view:

tree

Explanation

  • ‘arch’ : a view is declared as a record of the model ir.ui.view, the arch field must thus be declared as type=”xml” to be parsed correctly.
  • ‘tree’ : is the root element of list views

Here is an screenshot of implementation:

odootree

The graph views is used to visualize aggregations over a number of records or record groups. Pivot technically isn’t a graph type, it displays the aggregation as a pivot table.

Here is an example of graph view:
graph

And pivot view:
pivot

Explanation

  • ‘graph’: is the root elemen of graph views.
  • ‘pivot’: is the root element of pivot views.
  • ‘row’ : groups by the specified field. For pivot tables, each group gets its own row.
  • ‘col’ : only used by pivot tables, creates column-wise groups.

And this windows action with three different values for view_mode:

action

Here is an screenshot of implementation of graph and pivot:

odoograph.png

odoopivot

What am I missing here? Let me know in the comments and I’ll add it in 😉

Advertisements

3 thoughts on “How to create a List, Graph and Pivot views in Odoo?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s