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

时间:2018-01-30 14:02:14

标签: odoo-8 odoo

我正在“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>

我尝试使用此代码,但显示内部服务器错误。我必须在“Total:”,“Taxes:”下添加我的内容。请检查并指导我。

1 个答案:

答案 0 :(得分:0)

模板的继承和查看它不一样,你需要使用: 对于您的情况,它是模板继承:

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

我希望这个答案对你有帮助。