Create a Dynamic Pivot Graph View in Odoo 17

CelineGeorge1 872 views 12 slides Sep 19, 2024
Slide 1
Slide 1 of 12
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12

About This Presentation

In odoo we can dynamically create views via sql query. This is immensely helpful when we want fields from various tables and make much more complex relationship between tables. Let’s see a simple example on how to achieve the same.


Slide Content

Create a dynamic pivot graph view in Odoo 17 Enterprise

Introduction Enterpr ise In odoo we can dynamically create views via sql query. This is immensely helpful when we want fields from various tables and make much more complex relationship between tables. Let’s see a simple example on how to achieve the same.

Enterprise

Explanation Enterprise Make sure to set the _auto attribute to false and then override the _init method. The code tools.drop_view_if_exists(self.env.cr, self._table) Is used to drop a view for the table of it exists. Now let's look at the sql query.

Enterprise

Explanation Enterprise Here we can use some of the fields from sale.order model like id , name, total and also the customer which is a connection to the res.partner table to make our dynamic view. Make sure that there is a related field in the view like how I have total_amount to stand in for amount_total . For the purposes of demonstration, this example is very simple with only one simple connection between two table, but much more complex relationships with multiple tables can be used to generate dynamic views.

Pivot view Enterprise Now let us define the graph and pivot vi ews

Enterprise

Enterprise

Enterprise

Conclusion Enterprise Hence this is how we can make dynamic pivot and graph views in Odoo 17.

For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com