Overview
Reports in Odoo are generated using QWeb templates. Default reports (invoice, sale order, delivery slip, etc.) are defined in XML templates inside core modules. Customization is done by inheriting the existing template rather than modifying the original file. This preserves upgrade compatibility.
Locate the Original Template
Example template used by the invoice report:
account.report_invoice_document
Example Original Template
<template id="report_invoice_document">
<t t-call="web.external_layout">
<t t-set="o" t-value="doc"/>
<div class="page">
<h2>Invoice</h2>
</div>
</t>
</template>
Inheriting the Template
Create a new XML file in your custom module and inherit the template.
Example:
<odoo>
<template id="custom_invoice_report"
inherit_id="account.report_invoice_document">
<xpath expr="//h2" position="after">
<p>
Custom message inside inherited report
</p>
</xpath>
</template>
</odoo>
Explanation:
- inherit_id references the original template.
- xpath selects the node to modify.
- position defines how the modification is applied.
Result
The custom module loads after the original module, applies the inherited template, and modifies the report structure without altering core code.
