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:



  • ‘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:


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:

And pivot view:


  • ‘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:


Here is an screenshot of implementation of graph and pivot:



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


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

  1. ozrlz says:

    Hello, thanks for the tutorial.

    Is there a way to have multiple form|tree views for a single model?

    If so, how do you specify which view_id does the action has to show?


    • insafamrani says:

      Hello Ozrlz, Yes If you want to specify the views to use, you can add a context attribute, and specify a view id for each type of view supported, exactly like the action’s view_id attribute. Here is an axample: context=”{‘form_view_ref’ : ‘module.view_id’, ‘tree_view_ref’ : ‘model.view_id’

      Liked by 1 person

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.