2


I'm trying to customize the invoice report in Odoo 11.
Problem is, xpath tag "replace" isn't working properly. Odoo 11 documentation says, and I quote:
"[replace:] the content of the inheritance spec replaces the matched node. Any text node containing only $0 within the contents of the spec will be replaced by a complete copy of the matched node, effectively wrapping the matched node".

Now, I need to totally replace the invoice lines in invoice PDF report, so I'm trying with a complete replace of the table tag:

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


This is supposed to erase the table and replace it with the simple string "Test".
But here's what I get - sorry, I would've loved to upload the image directly but I have low rep so link instead. :(
Why is it happening, and how can I succeed in replacing the node completely? Could someone please help me out?

SlyK
  • 175
  • 2
  • 14

2 Answers2

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
Vibha Kachhela
  • 184
  • 1
  • 6
  • I don't get any error, the traceback is perfectly clean, but the replace returns the report you can see in the image I linked above. :( – SlyK Feb 23 '18 at 13:36
  • Ohh... So I think you have any custom module in your database which gives you this table of invoice line. So check for that good luck.... – Vibha Kachhela Feb 24 '18 at 05:07
0

Try out this code.

<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>
Pranjal Gami
  • 214
  • 2
  • 15