Enable Dark Mode!
By: Aswathi PN

How to Create a Cohort View in Odoo 15

Functional Odoo 15

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. We can see the information for the next 15 days, weeks, months, and years on the cohort view. We can look at an example of this

Go to the Inventory > Reporting > Warehouse Analysis. We can see the cohort view


We can take a look at how to create a cohort view in odoo. First, we can create a module for that.

I have created a module named school management for this


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

class StudentAttendance(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")

Add security for that newly created model on the ir.model.access.csv folder


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

<menuitem id="school_assignment"

Here we give 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 one thing that must do add the “web_cohort” as a dependent 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 show the cohort view. And add a string for that view also set the time frame to show the view date_start is the starting date and date_stop is the ending date that we will define on the model. And we can set the interval, the interval has day, weak, month, and year. here we choose the interval as day and the mode is two types retention and churn. Churn will start from zero and that will be increased to zero. Retention will start from 100 percent and decrease to zero. Here we choose the mode as churn.

Install the module open the school management module and go to the assignments menu. We can see the cohort view of the assignments.


The above figure shows the cohort view on the UI. In this way, we can create a cohort view in odoo15. I believe the points discussed above are very clear for you and it is helpful to understand the cohort view in Odoo.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




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