Odoo xpath表达式规则



我正在Odoo中开发一个Qweb报告,我需要使用xpath表达式来替换一些内容。

这是需要进行内容替换的主要模板:

<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

这是我使用xpath表达式替换内容的另一个模板:

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

这不起作用。有人知道为什么?

感谢阅读!

您必须使用inherit_id继承原始模板。然后您就可以使用XPath表达式来更改或添加新代码。

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

最新更新