Aggregate feature in list view odoo 17.pptx

CelineGeorge1 1,028 views 15 slides Oct 14, 2024
Slide 1
Slide 1 of 15
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
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

In Odoo 17, the tree view can be enhanced with aggregation features, enabling users to summaries such as totals, averages, and counts directly within the view. These features offer quick insights into the data, eliminating the need for separate reports.


Slide Content

Aggregate feature in list view odoo 17 Enterprise

Introduction Enterpr ise In Odoo 17, the tree view can be enhanced with aggregation features, enabling users to summaries such as totals, averages, and counts directly within the view. These features offer quick insights into the data, eliminating the need for separate reports.

Functions Enterprise The two main types of aggregate functions commonly used in Odoo are: sum avg

Sum() Enterprise In Odoo, the sum function is versatile and can be applied in different contexts, such as within tree views for displaying aggregated data or in Python code for programmatic calculations. 1. Using Sum in Tree Views 2. Using Sum in Python Code

Using Sum in Python Code Enterprise from odoo import models, fields, api class SaleOrder(models.Model): _inherit = 'sale.order' @api.model def get_total_amount(self, customer_id): orders = self.search([('partner_id', '=', customer_id)]) total_amount = sum(order.amount_total for order in orders) return total_amount

Explanation Enterprise In Python, the sum function to calculate the sum of a list of values. This can be useful in methods where you need to compute totals. The method get_total_amount searches for all sales orders for a given customer. It then calculates the total amount by summing the amount_total field of each order.

Sum in Tree Views(code) Enterprise <record id="vsale_order_tree_view" model="ir.ui.view"> <field name="name">sale.order.tree</field> <field name="model">sale.order</field> <field name="arch" type="xml"> <tree string="Sales Orders"> <field name="name"/> <field name="partner_id"/> <field name="amount_total" sum="Total"/> </tree> </field> </record>

Explanation Enterprise In a tree view, the sum attribute to display the sum of a column. This is particularly useful for numerical fields where we w ant to see the total directly in the list view. In this example, the amount_total field will display the sum at the bottom of the column in the tree view. In the next slide, we will see an example output demonstrating the use of the sum attribute in Odoo Sales. It calculates and displays the total sum at the bottom.

Example Enterprise

Avg Function Enterprise In Odoo, the avg function calculates and displays the average of a numeric field within views, especially in tree views. This feature offers quick insights into the average values of specific data columns directly in the list view, eliminating the need for separate reports.

Avg function Enterprise <record id="view_order_line_tree" model="ir.ui.view"> <field name="name">sale.order.line.tree</field> <field name="model">sale.order.line</field> <field name="arch" type="xml"> <tree string="Order Lines"> <field name="order_id"/> <field name="product_id"/> <field name="price_unit" avg="Average Price"/> <field name="product_uom_qty"/> </tree> </field> </record>

Explanation Enterprise In this example, the price_unit field will show its average value at the bottom of the column in the tree view. Odoo calculates this average by taking all the amounts into consideration, providing a comprehensive view of the average price unit across the displayed data set.

Additional Aggregate Functions Enterprise Besides the sum attribute, Odoo also supports other aggregate functions: Average: Calculate the average value of a field. Count: Count the number of records. Min: Find the minimum value. Max: Find the maximum value.

Enterprise Conclusion Hence we can use the aggregate feature in odoo 17 to further enhance the use, readability and overall user experience of 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