【问题标题】:How to replace template with my own content, xml Odoo 14如何用我自己的内容替换模板,xml Odoo 14
【发布时间】:2021-11-23 17:47:23
【问题描述】:

我需要用我自己的内容替换sale模块的模板variants

我的代码-xml:

<template id="my_variants" inherit_id="sale.variants">
  <xpath expr="." position="replace">
     <!--        <p>My codee, this is not shown</p>-->
  </xpath>
</template>

使用以前的代码我的新模板不起作用,我做错了什么?如何解决?

注意:使用&lt;t t-call = "web.layout"&gt; 与xpath 后面的所有内容;我的模板有效,但显示 JS 错误

带有错误 JS 的代码:

   <template id="my_variants" inherit_id="sale.variants">
      <xpath expr="." position="replace"><!-- template works but with error JS-->
        <t t-call="web.layout" >
         <!--        <p>My codee, my code, this is displayed and</p>-->
        </t>
      </xpath>
    </template>

JS 错误:

web.assets_common_lazy.js:4497 Uncaught (in promise) TypeError: Cannot 读取未定义的属性'user_context'

【问题讨论】:

    标签: python xml odoo qweb


    【解决方案1】:

    使用以下代码:

    <template id="my_variants" inherit_id="sale.variants">
        <xpath expr="." position="replace">
            <p>My codee, this is not shown</p>
        </xpath>
    </template>
    

    该段落将显示在Available Options中的商品价格左侧

    不要在variants 模板中使用&lt;t t-call="web.layout" &gt;product 模板已经这样做了。

    web.layout 通常在我们添加新布局时使用。

    【讨论】:

      猜你喜欢
      • 2021-08-18
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 1970-01-01
      • 2017-06-20
      • 1970-01-01
      相关资源
      最近更新 更多