Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
44776 Tampilan

I need to have headers report specific, I know I can inherit standard header and customize that but it becomes global header, If I inherit header in both reports it prints in one only which loads later ( later report replaces previous header). how can I have report spcific headers?

Avatar
Buang
Jawaban Terbai

  <div class="header">
            This Is Header
  </div>

use it before <div class="page">  in report,

to re-use make it as seperate template. then u can use <t t-call="module_name.template_id"/>

Avatar
Buang

Thanks @ Sajin Aziz

Jawaban Terbai

Hi Yogesh!

You actually have two options. The first is to create a new header template in the module reports, in the file layouts.xml (addons/report/views/layouts.xml). For example:

<template id="your_custom_layout_header">

<div class="header">

<div class="row">

<div class="col-xs-3">

<img t-if="company.logo" t-att-src="'data:image/png;base64,%s' % company.logo" style="max-height: 45px;"/>
<!-- All your custom code here -->

</div>
</div>
</div>

</template>

Which you can then load in your report.

<t t-call="report.your_custom_layout_header">

The second option is to use the header element in Odoo. Before the <div class="page"> tag you can then do this:

<div class="header">
           <h3>Header title</h3>
          <t t-esc="o.name"/>
  </div>

Avatar
Buang

I did it like your second example. But it does not have a separator line under it. I tried <hr> and it wanted </hr> as well. Then I added style of height. It didn't work. How do I get a bold horizontal line at the end of the header?

On the other hand, looking at your first example, I went to /usr/lib/python2.7/dist-packages/odoo/addons/report/views/layout_templates.xml and fount the templates for the odoo-supplied header and footer and used them as examples for my various customized headers and footers for my own various customized reports. Works great!

Dear Yenthe,
This solution is not working for odoo 14. I applied the above options, only header shows remaining data from the page gets blank.

Pls help how this can work for odoo 14. thanks