2


我正在尝试在 Odoo 11 中自定义发票报告。
问题是,xpath 标签“replace”无法正常工作。Odoo 11 文档说,我引用:
“[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”。
但这是我得到的- 对不起,我很想直接上传图片,但我的代表很低,所以链接。:(
为什么会这样,我怎样才能成功地完全替换节点?有人可以帮我吗?

4

2 回答 2

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
于 2018-02-23T13:06:01.197 回答
0

试试这个代码。

<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>
于 2018-02-23T04:22:47.893 回答