This question has been flagged
2 Replies
4368 Views

Hi!

At the moment I am working on a product label which the user can print after it is delivered into stock.

My qestion is: is there a way to do a loop on the quantity only within the QWeb-XML? E.g. products_qty = 20 it will do something like

<t t-for="quantity" t-in="move.products_qty">
    Product-Name - EAN...
</t>

(which is not working) and print the label 20times. 

Avatar
Discard
Best Answer

Try this,

 <t t-foreach="range(1, move.products_qty + 1)"  t-as="r">
       <p t-esc="r"/>

       <!--Product Name  -->

</t>

Avatar
Discard
Author

Thank you Sir! With just a little change it works perfectly:

Author Best Answer

The above code in my comment was unfortunately not printet.

As products_qty is a float I just changed it to int():
 <t t-foreach="range(1,
int(move.products_qty) + 1)"  t-as="r">

       <p t-esc="r"/>
</t>

Avatar
Discard