Skip to Content
Menu
This question has been flagged
2 Replies
8355 Views

Hello,

I am working in a custom module and, as the title says, I am trying to modify the invoice report template. What I am trying to achieve is: 

  • The user creates an invoice.

  • The invoice created has one or more extra pages with some custom details.

  • These new pages have their own header and footer. It is like get two different (but related) reports at once.

What I have done is:

  • I have created two new models, invoice.details and invoice.details.line.

  • When the user creates a new invoice, an invoice.details and its lines are created and related to this new invoice.

  • Then I created a new view that inherits the template view and adds a new table with the data of the invoice.details.lines.

  • Now I see this new table in the invoice report preview, but if I download the invoice report or try to print it, my changes aren't there so I think there are more templates that I have to modify but I can't find them.


The template that I am modifying at this moment is the "external_layout_standard" located in odoo/addons/web/views/report_templates.xml.


Where can I find the other templates that I have to modify?


Thank you.


Avatar
Discard
Best Answer

Hi,

If you are looking to make changes in the account invoice report, you have to make changes inside this template, ie template with id  report_invoice_document in path  odoo/addons/account/views/report_invoice.xml

If you are new to Odoo and if you want to know how to make changes inside existing reports, you can check this: Customize Existing Reports in Odoo


And if you need to show different header and footer for this pages, better you define the new contents as a new report template with the header and footer as you need.


Then you can call this template here:

<template id="report_invoice">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o">
<t t-set="lang" t-value="o.invoice_user_id.sudo().lang if o.type in ('in_invoice', 'in_refund') else o.partner_id.lang"/>
<t t-call="account.report_invoice_document" t-lang="lang"/>
<t t-call="custom_module.report_invoice_custom" t-lang="lang"/>
</t>
</t>
</template>


Thanks

Avatar
Discard
Author

Hi,

Thanks for your help. I have tried to inherit the report_invoice_document template and it Works great, now if I download my invoice report or try to print it my custom template is still shown, nice!

I am trying to make it working the way you suggest in your answer in order yo show a different header and footer for this pages, but I added "<t t-call="custom_module.report_invoice_custom" t-lang="lang"/>" to the report_invoice template and it does not show my template. I tried the following:

* Added the line using a template that inherits the report_invoice template and adds the line using xpath.

* Added the line manually in the report_invoice template.

* Copied my custom template in the same file as report_invoice template (odoo/addons/account/views/report_invoice.xml) and then added the line manually.

I don't know why it is not working and neither know what more can I try. Can you help me?

Thank you!