Enable Dark Mode!
how-to-create-a-cohort-view-in-odoo-15.jpg
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

how-to-create-a-cohort-view-in-odoo-15-cybrosys

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

how-to-create-a-cohort-view-in-odoo-15-cybrosys

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

Id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
student.assignment,student_assignment,model_student_assignment,,1,1,1,1

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

<menuitem id="school_assignment"
         name="Assignments"
         action="action_school_cohort"
         parent="school_menu"
/>

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>
</record>

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"
               mode="churn"/>
   </field>
</record>

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.

how-to-create-a-cohort-view-in-odoo-15-cybrosys

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.



0
Comments



Leave a comment

 
whatsapp
location

Calicut

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

location

London

Cybrosys Limited
Alpha House,
100 Borough High Street, London,
SE1 1LB, United Kingdom

location

Kochi

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

location

Bangalore

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

Send Us A Message