如何在odoo中的模板标签内的foreach中给出当前迭代

How to give current iteration in foreach inside template tag in odoo

如何在不创建新变量来存储迭代次数的情况下知道模板内部 foreach 中的当前迭代次数?我不能在 odoo 文档中使用示例 https://www.odoo.com/documentation/11.0/reference/qweb.html#reference-qweb 例如:

$as_all
    the object being iterated over
$as_value
    the current iteration value, identical to $as for lists and integers, but for mappings it provides the value (where $as provides the key)
$as_index
    the current iteration index (the first item of the iteration has index 0)
$as_size
    the size of the collection if it is available
$as_first
    whether the current item is the first of the iteration (equivalent to $as_index == 0)
$as_last
    whether the current item is the last of the iteration (equivalent to $as_index + 1 == $as_size), requires the iteratee’s size be available

你可能错过了这部分from the docs:

$as will be replaced by the name passed to t-as

示例:

<t t-foreach="some_list" t-as="var_name">
  <p> I'm in loop <t t-esc="var_name_index"/></p>
</t>