Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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?
This is pretty simple and straight forward.
When we define our loop like this:
<t t-foreach="people" t-as="person">
<th scope="row"><span t-raw="person_index"/></th>
To get the current index/position of the person with the loop you can do person_index. i.e your variable_index or any other available variable withing the context of qweb loop.
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
About This Community
This platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 11/10/14, 5:01 PM|
|Seen: 21513 times|
|Last updated: 4/29/18, 11:53 AM|