Cohort View in Odoo 16

TEAM-BASSAM
July 11, 2023
cohort-view

Visualizing the records in the form of different views with an option to filter on the basis of different measures and time periods can be extremely helpful for the organization to keep an updated track of all the operations taking place. In Odoo there are different types of views that provide different representations of the records. Form View, Kanban View, Tree View, Calendar View, Cohort View, etc. are some of the different types of views available in Odoo. In this blog, we will mainly focus on the features and functionalities associated with Odoo’s ‘Cohort View’ and also look into the steps involved to achieve a cohort view in Odoo 16.

In Odoo, the cohort view allows you to analyze the data in a specific time period. It can be considered as a reporting view that helps to track and analyze data over time.

The image below shows the Cohort View present in Odoo’s inventory module. This can be accessed by going through the following steps –

Inventory → Reporting → Warehouse Analysis

odoo-cohort-view

Now let us look into the steps involved to achieve a cohort view in Odoo 16.

To create a cohort view for our custom model, we will have to create the required folders and files in our custom module. Here, we have named our custom module’ ‘bi_cohort_view’, as shown in the image below.

The image below shows the contents of the file ‘employee_details.py’ under the ‘models’ folder.

employee-details

The image below shows the contents of the file ‘ir.model.access.csv’ under the ‘security’ folder.

DOWNLOAD ERP

After this, we can create the required views for the model. This can be done in the.

‘employee_details.xml’ file under the ‘views’ folder. The content of this XML file is shown below.

content-of-this-xml-file

In the above image, we have created ’ir.ui.view’ records for form, tree, and cohort views for our model. We have also created an ‘ir.actions.act.window’ (i.e., action for our custom model) and added a menu item for the same.

The image below shows the ir.ui.view described for the cohort view.

odoo-cohort-view

In this, we have added a cohort string and also set ‘date_start’ as ‘create_date’ and ‘date_stop’ as ‘date’(which was declared in our custom module). Also, we can define the ‘interval’ as day, week, month, or year, and the ‘mode’ is set as ‘churn’.

After this include the appropriate files in the ‘__manifest__.py’ file as shown in the image below. Also, add  “web_cohort” as a dependent module.

cohort-view

After creating the above-mentioned files and folders, we can install our module on our database. After installation, we can see the ‘Employee Details’ menu under the ‘Configuration’ menu.

configuration-menuThe image below shows the list/tree view of the model.

list/tree-view-of-the-model.

In the above image, we can see the icons for the list view and cohort view in the right corner. When we clicked on the cohort view icon, we can access the cohort view for our model.

cohort-view-for-our-model

Using the above example, you can create the ‘Cohort View’ for your custom model, which will give a better understanding and give a report representation of your data.

Request Your Free Quote

"Unlock the Full Potential of Your Business with Odoo ERP!"

"Get a Cost Estimate for Your ERP Project, Absolutely FREE!"

Get a Free Quote

Leave a Reply

Your email address will not be published. Required fields are marked *