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

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

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屏幕中不起作用?

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <templates id="template" xml:space="preserve">
  3. <t t-name="ProductTotalSalesScreen" owl="1">
  4. <t t-set="data_sales" t-value="sales_data"/>
  5. <div class="top-content">
  6. <div class="button back" t-on-click="back">
  7. Back
  8. </div>
  9. </div>
  10. <t t-foreach="[1, 2, 3]" t-as="i">
  11. <p><t t-esc="i"/></p>
  12. </t>
  13. </t>
  14. </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?

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <templates id="template" xml:space="preserve">
  3. <t t-name="ProductTotalSalesScreen" owl="1">
  4. <t t-set="data_sales" t-value="sales_data"/>
  5. <div class="top-content">
  6. <div class="button back" t-on-click="back">
  7. Back
  8. </div>
  9. </div>
  10. <t t-foreach="[1, 2, 3]" t-as="i">
  11. <p><t t-esc="i"/></p>
  12. </t>
  13. </t>
  14. </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

尝试这个,如果对你有用

  1. <t t-foreach="[1, 2, 3]" t-as="i" t-key="i">
  2. <p><t t-esc="i"/></p>
  3. </t>
英文:

Try this if it works for you

  1. &lt;t t-foreach=&quot;[1, 2, 3]&quot; t-as=&quot;i&quot; t-key=&quot;i&quot;&gt;
  2. &lt;p&gt;&lt;t t-esc=&quot;i&quot;/&gt;&lt;/p&gt;
  3. &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:

确定