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

Replacing default header for custom one in customized invoice report

By
E.M.
on 9/16/15, 8:17 PM 1,328 views

In Odoo v8 I have created a custom template for invoices.

I would like to replace the standard header with a custom one, i.e. replace <t-call="report.external_layout">; with <t t-call="cool_header">

Instead of using the header directly into the new invoice template I would like to put in separate view as it could be reused.

Should a new view be created? If so which key paremeters should be used? (view type, child field, etc.)

Thanks,

5

Parikshit

--Parikshit--
939
| 6 3 8
Ahmedabad, India
--Parikshit--

Working as an OpenERP/Odoo developer both experience in web and addons. you can contact me at:

E-mail : parikshitvaghasiya@gmail.com

Blog : parikshitvaghasiya.blogspot.in

Stackoverflow : http://stackoverflow.com/users/5089106/parikshit-vaghasiya

Parikshit
On 9/17/15, 1:17 AM

Hello,

For account report code in your xml file :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="account.report_invoice_document">
Your Account Report
</template>
</data>
</openerp>

For Header Footer you have to do like this :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="account.report_invoice_document">
<t t-foreach="docs" t-as="o">
<t t-call="module_name.extend_layout">
Your Report
</t>
</t>
</template>
</data>
</openerp>

Now, Code for Custom Header and Footer :

 <template id="extend_layout">
<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="module_name.report_header" />
<t t-raw="0" />
<t t-call="module_name.report_footer" />
</template>

<template id="report_header">
<div class="header">
Your Report Header
</div>
</template>

<template id="report_footer">
<div class="footer">
Your Report Footer
</div>
</template>

Hope this will help you..!!
Thank you !

Thanks Parikshit, if I understood your answer right, you suggest to create a custom module with a xml file with the definitions to create both footer and header. I am fine with creating the templates through the GUI, but then I don't know how can I refer to them in my custom template report.

E.M.
on 9/17/15, 1:58 AM

this line consider your header footer and call your custom header and footer.."module_name.extend_layout" and extend_layout is id of template as shown in 3rd part . thanks !!

Parikshit
on 9/17/15, 2:42 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: 9/16/15, 8:17 PM
Seen: 1328 times
Last updated: 11/15/15, 6:13 PM