1
votes

I'm trying to customize a view in Odoo V12 adding with "xpath" expression some content but it's not working.

This is the place where the content needs to be added. enter image description here

I'm using the next code for inheriting the template and for making the changes.

<record id="education_calendar_website_event_template" model="ir.ui.view">
        <field name="name">Education calendar website event</field>
        <field name="inherit_id" ref="website_event.index" />
        <field name="arch" type="xml">
        <xpath expr="/t[1]/t[1]/div[1]/div[1]" position="inside">
            <div id="website_calendar_events" style="display: none;">
                <ul>
                    <t t-foreach="event_ids" t-as="event">
                        <li>
                            <p class="website_event_data" id="e_data_1">
                                <t t-esc="event.id" />
                            </p>
                        </li>
                    </t>
                </ul>
            </div>
        </xpath>
        </field>
    </record>

I tried the next expression too and not working: - //div[@id='oe_structure_website_event_index_1']

Anyone knows how to inherit data and modify/add existing templates? Thanks for reading!

1

1 Answers

2
votes

You need to use the template tag and specify the id of the template to alter with the inherit_id attribute.

<template id="event_ids" inherit_id="website_event.index">
    <xpath expr="//div[@id='oe_structure_website_event_index_1']" position="inside">
        <div id="website_calendar_events">
            <ul>
                <t t-foreach="event_ids" t-as="event">
                    <li>
                        <p class="website_event_data" id="e_data_1">
                            <t t-esc="event.id"/>
                        </p>
                    </li>
                </t>
            </ul>
        </div>
    </xpath>
</template>