【问题标题】:Odoo 11 QWeb Report: xpath tag "replace" not replacingOdoo 11 QWeb 报告:xpath 标签“替换”不替换
【发布时间】:2018-02-22 22:11:09
【问题描述】:


我正在尝试在 Odoo 11 中自定义发票报告。
问题是,xpath 标签“replace”不能正常工作。 Odoo 11 documentation 说,我引用:
“[replace:] 继承规范的内容替换了匹配的节点。规范内容中仅包含 $0 的任何文本节点都将被匹配节点的完整副本替换,从而有效地包装了匹配节点”。

现在,我需要完全替换发票 PDF 报告中的发票行,所以我尝试完全替换表格标签:

<template id="invoice_gross_amount_document"
          inherit_id="account.report_invoice_document">
    <xpath expr="//div/table[@name='invoice_line_table']"
           position="replace">
        <p>TEST</p>
    </xpath>
</template>


这应该会擦除表格并将其替换为简单的字符串“Test”。
但是here's what I get - 抱歉,我很想直接上传图片,但我的代表很低,所以改为链接。 :(
为什么会发生这种情况,我怎样才能成功地完全替换节点?有人可以帮帮我吗?

【问题讨论】:

  • 删除/table之前的'div'标签并再次运行。
  • @KevalMehta 它不起作用,不断添加“TEST”而不删除表本身。

标签: xml xpath odoo qweb odoo-11


【解决方案1】:
**Odoo 11 QWeb Report: xpath tag “replace” not replacing**

 Can you please tell me what error you got while replace the table?

 I used below code and inherit the invoice report.
<odoo>
    <data>
        <template id="invoice_gross_amount_document" inherit_id="account.report_invoice_document">
            <xpath expr="//table[@name='invoice_line_table']" position="replace">
                <h1>TEST</h1>
            </xpath>
        </template>
    </data>
</odoo>

And get the output that you can see in my Image. 

[1]: https://i.stack.imgur.com/OZK4h.png

【讨论】:

  • 我没有收到任何错误,回溯非常干净,但是替换返回的报告您可以在我上面链接的图像中看到。 :(
  • 哦...所以我认为您的数据库中有任何自定义模块可以为您提供此发票行表。所以检查一下好运....
【解决方案2】:

试试这个代码。

<template id="invoice_gross_amount_document" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']//table[@class='table table-condensed']" position="replace">
    <h1>TEST</h1>
</xpath>
</template>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-16
    • 1970-01-01
    相关资源
    最近更新 更多