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.
Size: 762.75 KB
Language: en
Added: Sep 19, 2024
Slides: 12 pages
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