I'm developing a Qweb report in Odoo and I need to use xpath expressions for replacing some content.
This is the main template where is needed to make the replace of the content:
<template id="report_saleorder2_template">
<t t-name="report_saleorder2_template">
<t t-call="web.external_layout">
<div class="page">
<div class="oe_structure" />
<div class="row" id="report_data_0">
<h1>Annual voluntary contribution to Fecoas - Alcaste school</h1>
//more code
This is the other template where I'm tying to use the xpath expression for replacing the content:
<template id="report_saleorder3_template">
<t t-name="report_saleorder3_template">
<t t-call="custom_v12_reports.report_saleorder2_template" t-lang="doc.partner_id.lang" />
<xpath expr="//div[@id='report_data_0']/h1[1]" position="replace">
<h1>Annual AMPA's member fee Alcaste school</h1>
</xpath>
</t>
</t>
</template>
This is not working. Someone knows why?
Thanks for reading!
You have to inherit the origin template with inherit_id
. Then you're able to use XPath expressions to change or add new code.
<template id="report_saleorder3_template"
inherit_id="module_name.report_saleorder2_template">
<xpath expr="//div[@id='report_data_0']/h1[1]" position="replace">
<h1>Annual AMPA's member fee Alcaste school</h1>
</xpath>
<!-- and other XPath expressions -->
</template>