Search code examples
odoo-8odoo

Inheriting template tags and adding custom fields?


I am working on POS module in "POS.xml" file it was containing below template code which I have to inherit that template tag to my module. Exsiting code:

<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>

In my module 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>

I tried with this code but it was showing Internal server error.I have to add my content under "Total:","Taxes:".Please check and guide me.


Solution

  • The inheritance of a template and view it's not the same, you need to use: To your case it's a template inheritance:

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

    I hope this answer can be helful for you.