I would like to make a loop to print elements an exact amount of times. Something like this:
<t t-for="o.label_qty" >
...
</t>
Where o.label_qty is an integer number.
But I can use only a t-foreach loop in qweb:
<t t-foreach="o.pack_operation_ids" t-as="l" >
...
</t>
Is there a way to do this?
If not I'm thinking the only solution is to create a dummy list with o.label_qty elements and write it in the foreach.
The t-foreach directive accepts a Python expression.
So, you could use range() just like in Python for loops:
<t t-foreach="range(o.label_qty)" t-as="l">
...
</t>
yes it totally possible in Odoo Qweb Report you just need to add the below way to do somethings like this
<t t-foreach="o.pack_operation_ids" t-as="l" >
<td class="col-xs-1">
<span t-esc="l_index+1"/>
</td>
</t>
hear the <span> tag is print the total no of times loop will be executed while we are printing our qweb report.
index is the part of Qweb Template Engine so hear it is always start with 0 element.
I hope my answer may help you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With