odoo - 如何在odoo中的模板标签内的foreach中给出当前迭代
问题描述
如何在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
解决方案
您可能错过了文档中的这一部分:
$as
将替换为传递给的名称t-as
例子:
<t t-foreach="some_list" t-as="var_name">
<p> I'm in loop <t t-esc="var_name_index"/></p>
</t>
推荐阅读
- oracle-apex - 将 LIKE 运算符与 APEX 中文本字段的值一起使用
- python - 尝试使用 python 和 Google Colab 从数据框列中提取关键字
- docker - 有没有办法(比如说,以加密方式)证明 Web 服务中使用了特定的软件代码?
- javascript - 初学者寻求有关如何处理新节点/Webpack 项目的建议
- java - Java SQL 语句找不到符号
- javascript - NodeJs 中间件挂起
- azure - 我们可以在 ARM 部署脚本中使用 az rest 吗?
- python - 如何在 django 重新启动之前运行代码?
- javascript - Mocha 测试 - 无法通过使用 async/await 拒绝承诺的测试
- python - 如何在 Python 中获取“二进制”数组的 sha256