我创建了一个继承sale.report_saleorder
的自定义报告,我正在尝试添加自定义标头。
<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>
当我选择报告格式为&#39; HTML&#39;时,它的工作没有任何问题。但是,当我将其打印为&#39; PDF&#39;时,它不会呈现我的标题。这有解决方案吗?如何使用标题打印报告?
答案 0 :(得分:1)
如果您想使用自定义标头,则必须继承report.external_layout_header
,这一个:
<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="{"widget": "contact", "fields": ["address", "name"], "no_marker": true}" style="border-bottom: 1px solid black;" class="pull-left"/>
</div>
</div>
</div>
</t>
所以,你应该像这样继承标题:
<openerp>
<data>
<template id="custom_external_layout_header" inherit_id="report.external_layout_header">
<!-- [...] -->
</template>
</data>
</openerp>
答案 1 :(得分:0)
将自定义标头放在<div class="header">
例如:
<div class="header">
<span>hi</span>
<div>
答案 2 :(得分:0)
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