I'm trying to customize a report_invoice_document qweb report. Here is the source code:
<?xml version="1.0"?>
<t t-name="account.report_invoice_document">
<t t-call="report.external_layout">
<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>
<div class="page">
<div class="row">
<div name="invoice_address" class="col-xs-5 col-xs-offset-7">
<address t-field="o.partner_id" t-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": True}"/>
<span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>
</div>
</div>
<h2>
<span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice</span>
<span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
<span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>
<span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>
<span t-if="o.type == 'out_refund'">Refund</span>
<span t-if="o.type == 'in_refund'">Vendor Refund</span>
<span t-if="o.type == 'in_invoice'">Vendor Bill</span>
<span t-field="o.number"/>
</h2>
...
So I'm trying to replace "div[@class='page']" and build my own report with the following code and expect to see just the "Invoice_test_2" in my report when I print it out:
<odoo>
<data>
<template id="practichem_report_invoice_layout" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']" position="replace">
<div class="page">
<h2>Invoice_test_2</h2>
</div>
</xpath>
</template>
</data>
</odoo>
But I'm getting the following error:
ValueError: Can't validate view:
Element '<xpath expr="//div[@name='invoice_address']">' cannot be located in parent view
What am I doing wrong?
However, I can replace the <h2> tag with the following code and it works:
<template id="practichem_report_invoice_layout" inherit_id="account.report_invoice_document">
<xpath expr="//div[@class='page']//h2" position="replace">
<h2>Customer Invoice Report</h2>
</xpath>
</template>