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

Add image field for report header

By
Victor Godayer
on 3/26/15, 9:15 AM 1,645 views

Hi,

I try to extend res.company model in order to allow upload of a PNG image, and integrate it in generated report as header.

Here is my code, but I get an blank header, and can't figure out why.


My views for company configuration :

<record model="ir.ui.view" id="cap_company">

<field name="name">cap_company_form</field>

<field name="model">res.company</field>

<field name="inherit_id" ref="base.view_company_form" />

<field name="arch" type="xml">

<xpath expr="//page[@string='Report Configuration']/group" position="before">

<group string="Configuration Header">

<field name="document_header_png" />

</group>

</xpath>

</field>

</record>


My layout extension :

<template id="report_header_custom" inherit_id="report.external_layout_header">

<xpath expr="//div[@class='header']/div[@class='row']/div[@class='col-xs-3']" position="replace">

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

<img t-if="company.document_header_png" t-att-src="'data:image/png;base64,%s' % company.document_header_png" style="max-height: 45px;"/>

</div>

</xpath>

</template>


My model :

class company(osv.osv):

_inherit = 'res.company'

_columns = {

'document_header_png': fields.binary("Header PNG",),

}


And I double checkd my __openerp__.py which effectively have :


"depends": ["base", "report",],

"data": ['reports/external_layouts.xml','views/company.xml'


Thank you for your help     

1

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 4/30/15, 11:21 PM

Have you tried by simply putting the image file in static folder and giving its path. Please check whether it works. If yes, we can correct this. Also I don't think you need alter views for company configuration. Just need to inherit and override the report_layout_header like you did. You want to have the change in all reports? anyway first you just try by simply putting the image in static folder. Also check your "wkhtmltopdf" versions are correct. I have did overriding the report headers with images and worked.

Eg:


<template id="report_header_custom" inherit_id="report.external_layout_header">

<xpath expr="//div[@class='header']/div[@class='row']/div[@class='col-xs-3']" position="replace">

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

<img src='/your_module/static/img/header.png' style="max-height: 45px;"/>

</div>

</xpath>

</template>

Thanks, I finally achieve to do it following your recomendations

Victor Godayer
on 5/28/15, 11:36 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: 3/26/15, 9:15 AM
Seen: 1645 times
Last updated: 5/28/15, 11:36 AM