Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

[9.0] Can I use different headers and footers in different reports?

By
Mohamed Basheer
on 4/16/16, 2:57 AM 363 views

I used inherit to modify default headers and created two templates using different headers. But only one is displaying in each reports. Is there any way to use different headers and footers?

1

Yenthe

--Yenthe--
6676
| 7 7 8
Turnhout, Belgium
--Yenthe--

My Odoo blog: http://www.odoo.yenthevg.com/

My Twitter: https://twitter.com/Yenthe666

Yenthe
On 4/16/16, 5:40 AM

Hi Mohamed,

Yes you can and it is quite easy. When you look at a QWeb report in Odoo you will always see a call at the very top of the report to another template. For example for the sale report:

<template id="report_saleorder_document"> <t t-call="report.external_layout"> <!-- Lots of irrelevant code --> </t> </template>

This <t t-call="report.external_layout"> refers to the default report header in Odoo. When you look at that code you'll see this calls another two templates:

<template id="external_layout"> <!-- Multicompany --> <t t-if="not o and doc"> <t t-set="o" t-value="doc"/> </t> <t t-if="o and 'company_id' in o"> <t t-set="company" t-value="o.company_id"></t> </t> <t t-if="not o or not 'company_id' in o"> <t t-set="company" t-value="res_company"></t> </t> <t t-call="report.external_layout_header" /> <t t-raw="0" /> <t t-call="report.external_layout_footer" /> </template>

So if you create another template like the one above, which does a call to another (custom made) header & footer you can use them in your custom / other reports.
Something along the lines of:

<template id="external_layout_custom"> <!-- Multicompany --> <t t-if="not o and doc"> <t t-set="o" t-value="doc"/> </t> <t t-if="o and 'company_id' in o"> <t t-set="company" t-value="o.company_id"></t> </t> <t t-if="not o or not 'company_id' in o"> <t t-set="company" t-value="res_company"></t> </t> <t t-call="report.external_layout_header_custom" /> <t t-raw="0" /> <t t-call="report.external_layout_footer_custom" /> </template>

Don't forget to also create XML templates for external_layout_header_custom and external_layout_footer_custom too.

Yenthe

Thanks for the detailed answer. this is applicable in custom reports, right? Is this possible while inheriting a report? I used the inherit for the headers too.

Mohamed Basheer
on 4/16/16, 6:27 AM

No problem! Yes this is applicable in custom reports and also in already existing ones.

Yenthe
on 4/18/16, 3:20 AM

Thank you.

Mohamed Basheer
on 4/18/16, 7:01 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/16/16, 2:57 AM
Seen: 363 times
Last updated: 4/18/16, 7:01 AM