Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4947 Zobrazení

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
Zrušit
Nejlepší odpověď

Try this,

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

       <!--Product Name  -->

</t>

Avatar
Zrušit
Autor

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

Autor Nejlepší odpověď

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
Zrušit