英文:
t-foreach loop in POS template screen is not working
问题
I'm working on Odoo 16 and tried to create a custom screen in POS.
在Odoo 16上工作,尝试创建自定义POS屏幕。
Is there any particular reason why the following template is not working in my custom POS screen?
是否有特定的原因,导致以下模板在我的自定义POS屏幕中不起作用?
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="ProductTotalSalesScreen" owl="1">
<t t-set="data_sales" t-value="sales_data"/>
<div class="top-content">
<div class="button back" t-on-click="back">
Back
</div>
</div>
<t t-foreach="[1, 2, 3]" t-as="i">
<p><t t-esc="i"/></p>
</t>
</t>
</templates>
以下是问题的原因是t-foreach部分。当我删除它时,一切都按预期工作,我的屏幕显示出返回按钮。一旦我实现了t-foreach部分,然后在尝试显示我的自定义屏幕时,浏览器控制台中出现了"undefined"错误。
问题的原因是t-foreach部分。当我删除它时,一切都按预期工作,我的屏幕显示出返回按钮。一旦我实现了t-foreach部分,然后在尝试显示我的自定义屏幕时,浏览器控制台中出现了"undefined"错误。
Generally, I can't use t-foreach in my POS templates and I always get the 'undefined' error.
通常情况下,我不能在我的POS模板中使用t-foreach,而且总是会出现"undefined"错误。
Does anyone know why? Any hint would be helpful.
有谁知道原因吗?任何提示都会有帮助。
英文:
I'm working on Odoo 16 and tried to create a custom screen in POS.
Is there any particular reason why the following template is not working in my custom POS screen?
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="ProductTotalSalesScreen" owl="1">
<t t-set="data_sales" t-value="sales_data"/>
<div class="top-content">
<div class="button back" t-on-click="back">
Back
</div>
</div>
<t t-foreach="[1, 2, 3]" t-as="i">
<p><t t-esc="i"/></p>
</t>
</t>
</templates>
What causes the problem is the t-foreach section. When I remove it, everything works as expected and my screen appears with the back button. As soon as I implement a t-foreach section, then an 'undefined' error appears in my browser console, when I try to display my custom screen.
Generally, I can't use t-foreach in my POS templates and I always get the 'undefined' error.
Does anyone know why? Any hint would be helpful.
答案1
得分: 2
尝试这个,如果对你有用
<t t-foreach="[1, 2, 3]" t-as="i" t-key="i">
<p><t t-esc="i"/></p>
</t>
英文:
Try this if it works for you
<t t-foreach="[1, 2, 3]" t-as="i" t-key="i">
<p><t t-esc="i"/></p>
</t>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论