Home Blog Perform Operations Like Sum/Average On The ListView In Odoo
Perform Operations Like Sum/Average On The ListView In Odoo

Perform Operations like Sum/Average on the ListView in Odoo

Tree View, also known as ListView, shows multiple records in the form of a list (rows and columns). Each row represents a record of the database table.

Tree View is used to show important data, i.e. only some important columns of the model/table. You can do various operations on Tree view that as sorting, filtering, and grouping by.

Quotes can be thought of as a "presentation layer" of an Opportunity in that a user can create a PDF of the Quote and email it to a Contact straight from Sales.

The total amount of the cost of goods or services billed to a customer, usually covering purchases made or services rendered within a specified period, is present at the end of each quotation.

The total is present at the end of the quotation in the form view. This total is of a single quotation.

Sum and Average in Odoo List View

But what if we want the total of all the quotations so far at the end of the list/tree view? Or if we want the total of all the invoices or if we want the total of any number of records. How to achieve that?

We can do so by using this simple syntax –

<field name=”amount_total”sum=”Total Tax included” widget=”monetary”


In the above code,

          amount_total= name of the field whose aggregate is to be calculated

          sum = name of the attribute

          widget = use for displaying the currency symbol

You can use any field you want to calculate the total of and not only just total, but you can also perform various other attributes on the tree view.

You can calculate the total of a field or the average value of a field in all the records etc.

Just specify the attribute you want to use, for example:

    -    sum for total

    -   avg for calculating the average

    -    min for the minimum value

    -    max for maximum value

Using this in the tree view would give you the total amount of all the records in that tree view.

Sum and Average in Odoo List View

We can use this attribute anywhere to calculate the aggregate at the end of any tree view of the total. In this example, we have to use the sum attribute on the total shown at the end of all the records/quotations.

You can see the code here:


Sum and Average in Odoo List View

Just make sure you use the field and its attribute​ correctly in the tree view.

 Subscribe our newsletter for Odoo, technical insights, and more!


If you have a query related to the above-mentioned tips, feel free to ask in the Comment Section. We try our best to help as much as we can.

If you are looking for an Odoo Consulting Services Provider for your projects, Contact Kanak infosystems LLP., as we are provided the best Odoo Open ERP Solution to our global clients.

In case if you want our services Contact Us by fill the form or directly Call us @ +91-9818108884 or Email at - [email protected]

Get in touch wit​h us!

Protected by reCAPTCHA, Privacy Policy & Terms of Service apply.
Leave a Comment

Your email address will not be published.

Submit
Your comment is under review by our moderation team.