Chapter 6 - Odoo 15 Development Book

Pivot view

There are many views in Odoo. One of them is the cohort view, which gives a good analysis of data in a specific time frame. On the cohort view, we can see the information for the next 15 days, weeks, months, and years. We can look at an example of this Go to the Inventory > Reporting > Warehouse Analysis. We can see the cohort view.


At first, we can add a new model for that and define some fields

                            class StudentAssignment(models.Model):
  _name = 'student.assignment'
  student_id = fields.Many2one('school.student.record', string="Student")
  name = fields.Char(string='Name')
  date = fields.Date(string="Date")
  attachment = fields.Binary(string="Attachment")

Then create a menu item and set an action for that menu item.

<menuitem id="school_assignment"

Here we given the action as “action_school_cohot”, then create an action with id “action_school_cohot.”

<record id="action_school_cohort" model="ir.actions.act_window">
  <field name="name">Assignment Analysis</field>
  <field name="type">ir.actions.act_window</field>
  <field name="res_model">student.assignment</field>
  <field name="view_mode">tree,form,cohort</field>

Also there is a one thing that must do add the “web_cohort” as a dependant module on the manifest.

Next we can add a cohort view for the model “student.assignment.”

<record id="view_cohort_cohort" model="ir.ui.view">
  <field name="name">student.assignment.cohort</field>
  <field name="model">student.assignment</field>
  <field name="arch" type="xml">
      <cohort string="Assignments" date_start="create_date" date_stop="date" interval="day"

We can use the cohort tag to shows the cohort view. date_start is the starting date and date_stop is the ending datel. And we can set the interval, it can be day, week,month and year. Mode are two types retention and churn. Churn will be start from zero and that will be increased to zero. Retention will be starts from 100 percentage and decreased to zero.



Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message