簡體   English   中英

如何在 POS 客戶視圖中添加新跨度? 奧多 14

[英]How to add a new span in POS customer view? Odoo 14

我想在 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>

//清單.py

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

我的代碼有什么問題? 請問有什么幫助嗎? 謝謝。

如果我在 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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM