【问题标题】:How to add a new span in POS customer view? Odoo 14如何在 POS 客户视图中添加新跨度?奥多 14
【发布时间】:2021-08-19 17:45:57
【问题描述】:

我想在 POS 客户视图中添加一个跨度。我尝试使用此代码,但不起作用。

//customer.xml

<?xml version="1.0" encoding="UTF-8" ?>
<templates id="point_of_sale.template" xml:space="preserve">
<t t-extend="ClientDetailsEdit">
        <t t-jquery=".client-details-right" t-operation="append">
            <div class="client-detail">
                <span class="label">Test</span>

            </div>
        </t>
    </t>

</templates>

//manifest.py

"qweb": [
        'static/src/xml/customer.xml',
        ],

我的代码有什么问题?请问有什么帮助吗?谢谢。

【问题讨论】:

    标签: javascript python xml odoo


    【解决方案1】:

    如果我在 Odoo 插件中查看扩展的示例,模板是这样声明的

    <templates id="template" xml:space="preserve">
    

    在您的情况下,您可以像这样声明模板

    <templates id="point_of_sale.template" xml:space="preserve">
    

    当您编写此id="point_of_sale.template" Odoo 时,在您的模块中将覆盖基本模板。但在模板的逻辑中,t-name 在所有模块中必须是唯一的。

    如果我按照这个逻辑你应该写:

    <?xml version="1.0" encoding="UTF-8" ?>
    <templates id="template" xml:space="preserve">
    <t t-extend="ClientDetailsEdit">
            <t t-jquery=".client-details-right" t-operation="append">
                <div class="client-detail">
                    <span class="label">Test</span>
    
                </div>
            </t>
        </t>
    
    </templates>
    

    在此解决方案中,您不会覆盖模板 point_of_sale.template,但您将创建一个新模板将扩展 t-name ClientDetailsEdit

    PS:有关更多信息,我查看 addons/iap/statis/src/xml/iap_template.xml

    代码是

    <?xml version="1.0" encoding="UTF-8"?>
    <template id="template" xml:space="preserve"> <!-- Id is only template -->
    
        <!-- LAYOUT TEMPLATES -->
        <div t-name="iap.redirect_to_odoo_credit">
            <t t-if="data.body">
                <div t-raw="data.body"/>
            </t>
            <t t-if="!data.body">
                <t t-if="data.message">
                    <span t-esc="data.message"/>
                </t>
                <t t-if="!data.message">
                    <span>Insufficient credit to perform this service.</span>
                </t>
            </t>
        </div>
    
        <t t-extend="DashboardMain"> <!-- And extend template here -->
            <t t-jquery=".o_web_settings_apps" t-operation="after">
                <div class="o_web_settings_iap"></div>
            </t>
        </t>
        
        <div t-name="iap.buy_more_credits" class="mt-2 row">
            <div class="col-sm">
                <button class="btn btn-link buy_credits"><i class="fa fa-arrow-right"/> Buy credits</button>
            </div>
        </div>
    </template>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多