This page of the documentation describes variables that can be used in a t-foreach loop in Qweb, but doesn't provide any examples of how to access those variables. I was thinking that I could use the $as_index variable to list line numbers on a sales order, but everything I have tried causes an error. Can anyone provide an example of how to output the index? Or, even better, the index + 1, since it starts at zero?
I have tryed this:
<t t-set="i" t-value="1"/>
<tr t-foreach="o.order_line" t-as="l">
<td> <span t-esc="i"/> </td>
<t t-set="i" t-value="i+1"/>
When the loop finishes, the ounter resets to 1. Does anyone kow a way to update a variable outside the loop? I would like to define a variable before the loop and set it to false. If I find what I am looking for inside the loop I would like to set the value of the variable to True. This var would later be used as a condition if a div is visible or not.
Any help is appreciated. Thx
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
|Asked: 11/10/14, 5:01 PM|
|Seen: 9570 times|
|Last updated: 12/21/15, 8:42 AM|