t-foreach循环在POS模板屏幕中不起作用。

huangapple go评论63阅读模式
英文:

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

&lt;t t-foreach=&quot;[1, 2, 3]&quot; t-as=&quot;i&quot; t-key=&quot;i&quot;&gt;
   &lt;p&gt;&lt;t t-esc=&quot;i&quot;/&gt;&lt;/p&gt;
&lt;/t&gt;

huangapple
  • 本文由 发表于 2023年6月6日 03:46:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76409570.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定