Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Product Label - Is loop on product_qty in QWeb possible?

By
Mathias Neef
on 1/25/15, 5:15 PM 1,103 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. 

2
Sajin Aziz
On 1/26/15, 12:47 AM

Try this,

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

       <!--Product Name  -->

</t>

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

Mathias Neef
on 1/26/15, 2:18 AM
1
Mathias Neef
On 1/26/15, 2:22 AM

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>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/25/15, 5:15 PM
Seen: 1103 times
Last updated: 3/16/15, 8:10 AM