December 2018
Beginner to intermediate
404 pages
10h 14m
English
A common need in reports is to provide totals. This can be done using Python expressions to compute those totals.
After the closing tag of <t t-foreach>, we will add a final row with the totals:
<!-- Report footer content -->
<div class="row">
<div class="col-3">
Count: <t t-esc="len(docs)" />
</div>
<div class="col-2" />
<div class="col-2" />
<div class="col-3" />
<div class="col-2" />
</div>
The len() Python function is used to count the number of elements in a collection. Similarly, totals can also be computed using sum() over a list of values. For example, we could have used the following list comprehension to compute a total amount:
<t t-esc="sum([x.price for x in docs])" />
You can think of list comprehensions ...
Read now
Unlock full access