Serdar Eren
Serdar Eren

Reputation: 165

Why my custom report header is showing in html but not in pdf in Odoo v10?

I have created a custom report which inherits sale.report_saleorder and I am trying to add custom header.

<openerp>
    <data>
        <template id="report_saleorder_inherit" inherit_id="sale.report_saleorder">
            <xpath expr="t" position="before">
                <div class="head_wrap">
                    <div class="row">
                        <div class="col-xs-3">
                            <img t-if="res_company.logo" t-att-src="'data:image/png;base64,%s' %res_company.logo"
                                style="max-height: 45px;" />
                        </div>
                        <div class="col-xs-9 text-right" style="margin-top:20px;"
                            t-field="res_company.rml_header1" />
                    </div>
                    <div class="row zero_min_height">
                        <div class="col-xs-12">
                            <div style="border-bottom: 1px solid black;"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-6" name="company_address">
                            <span t-field="res_company.partner_id"
                                t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}'
                                style="border-bottom: 1px solid black; display:inline-block;" />
                        </div>
                    </div>
                </div>
            </xpath>
        </template>
    </data>
</openerp>

When I select report format as 'HTML', it is working without any problem. But when I print it as 'PDF', it doesn't render my header. Is there a solution for this? How can I print report with my header?

Upvotes: 2

Views: 1915

Answers (3)

Hilar AK
Hilar AK

Reputation: 1675

 1. sudo apt-get remove wkhtmltopdf --purge
 2. sudo wget
    https://downloads.wkhtmltopdf.org/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
 3. sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
 4. sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
 5. sudo cp /usr/local/bin/wkhtmltoimage /usr/bin

Upvotes: 0

vbt
vbt

Reputation: 805

Put your custom header inside <div class="header">

Eg :

<div class="header"> <span>hi</span> <div>

Upvotes: 0

ChesuCR
ChesuCR

Reputation: 9620

If you want to use a custom header you must inherit the report.external_layout_header, this one:

<t t-name="report.external_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;"/>
            </div>
            <div class="col-xs-9 text-right" style="margin-top:20px;" t-field="company.rml_header1"/>
        </div>
        <div class="row zero_min_height">
            <div class="col-xs-12">
                <div style="border-bottom: 1px solid black;"/>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-5">
                <div t-field="company.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}" style="border-bottom: 1px solid black;" class="pull-left"/>
            </div>
        </div>
    </div>
</t>

So, you should inherit the header like this:

<openerp>
    <data>
        <template id="custom_external_layout_header" inherit_id="report.external_layout_header">

        <!-- [...] -->    

        </template>
    </data>
</openerp>

Upvotes: 1

Related Questions