继承模板标签并添加自定义字段?

Inheriting template tags and adding custom fields?

我正在 "POS.xml" 文件中处理 POS 模块,它包含以下模板代码,我必须将该模板标签继承到我的模块。 现有代码:

<templates id="template" xml:space="preserve">
 <t t-name="OrderWidget">
        <div class="order-container">
            <div class="order-scroller touch-scrollable">
                <div class="order">
                    <ul class="orderlines">
                        <t t-if="orderlines.length === 0">
                            <li class="orderline empty">
                                Your shopping cart is empty
                            </li>
                        </t>
                    </ul>
                    <div class="summary clearfix">
                        <div t-attf-class="line #{orderlines.length === 0 ? 'empty' : ''}">
                            <div class='entry total'>
                                <span class="label">Total: </span> <span class="value">0.00 €</span>
                                <div class='subentry'>Taxes: <span class="value">0.00€</span></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </t>
<templates>

在我的模块中 gst_view.xml:

<template id="contact" inherit_id="point_of_sale.template">
    <xpath expr="//form/t/div/div/div/div/div/div/div/[@class='subentry']" position="after">
        <h1>FOO 2</h1>
    </xpath>
</template>

我尝试使用此代码,但它显示内部服务器 error.I 必须在 "Total:"、"Taxes:" 下添加我的内容。请检查并指导我。

模板和视图的继承是不一样的,需要使用: 对于您的情况,这是一个模板继承:

<t t-extend="OrderWidget">
    <t t-jquery="div[class='subentry']" t-operation="after">
        <h1>FOO 2</h1>
    </t>
</t>

希望这个回答对您有所帮助。