【问题标题】:Odoo xpath expression ruleOdoo xpath 表达式规则
【发布时间】:2020-06-23 04:25:33
【问题描述】:

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

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

感谢阅读!

【问题讨论】:

    标签: xpath odoo


    【解决方案1】:

    您必须使用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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多