在odoo 10中继承销售订单报告

Inherit sale order report in odoo 10

我已尝试通过继承和 xpath 添加新的销售订单报告开始页。但它不起作用。 这是代码:

<template id="report_saleorder_inherit" inherit_id="sale.report_saleorder">
<xpath expr="//t[@t-call='report.html_container']" position="before">
  <t t-call="report.html_container">
    <t t-call="report.external_layout">
      <div class="page">
        <h1>New Page</h1>
      </div>
    </t>
  </t>
</xpath>

但我在核心模块 Sale 中进行了编辑,如下所示,并且有效。

<template id="report_saleorder">
  <t t-call="report.html_container">
     <t t-call="report.external_layout">
        <div class="page">
            <h1>New Page</h1>
        </div>
     </t>
  </t>
<t t-call="report.html_container">
    <t t-foreach="docs" t-as="doc">
     <t t-call="sale.report_saleorder_document" t-
         lang="doc.partner_id.lang"/>
    </t>
</t>
</template>

如何在我的自定义模块中实现这一点?

在你的模块中添加 "sale" 模块的依赖并尝试下面的代码

<template id="report_saleorder_inherit" inherit_id="sale.report_saleorder"> 
<xpath expr="t" position="before">
    <t t-call="report.html_container">
        <t t-call="report.external_layout">
          <div class="page">
            <h1>New Page</h1>
          </div>
        </t>
      </t>
</xpath>
</template>