如何更新 PDF 报告 (qWeb) 中的默认 header?
How to update default header in PDF report (qWeb)?
我有一份 PDF 报告,使用 Odoo (v8) 中的 qWeb。我的报告有这行代码:
<t t-call="report.external_layout">
我想这一行是为了在 PDF 报告中插入预定义的 header。在 Settings -> Companies 中,相应公司的 Report Configuration 选项卡中,有如下内容:
<header>
<pageTemplate>
<frame id="first" x1="1.3cm" y1="3.0cm" height="21.7cm" width="19.0cm"/>
<stylesheet>
<!-- Set here the default font to use for all <para> tags -->
<paraStyle name='Normal' fontName="DejaVuSans"/>
<paraStyle name="main_footer" fontSize="8.0" alignment="CENTER"/>
<paraStyle name="main_header" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
</stylesheet>
<pageGraphics>
<!-- Set here the default font to use for all <drawString> tags -->
<setFont name="DejaVuSans" size="8"/>
<!-- You Logo - Change X,Y,Width and Height -->
<image x="1.3cm" y="27.7cm" height="40.0" >[[ company.logo or removeParentNode('image') ]]</image>
<fill color="black"/>
<stroke color="black"/>
<!-- page header -->
<lines>1.3cm 27.7cm 20cm 27.7cm</lines>
<drawRightString x="20cm" y="27.8cm">[[ company.rml_header1 ]]</drawRightString>
<drawString x="1.3cm" y="27.3cm">[[ company.partner_id.name ]]</drawString>
<place x="1.3cm" y="25.3cm" height="1.8cm" width="15.0cm">
<para style="main_header">[[ display_address(company.partner_id) or '' ]]</para>
</place>
<drawString x="1.3cm" y="25.0cm">Phone:</drawString>
<drawRightString x="7cm" y="25.0cm">[[ company.partner_id.phone or '' ]]</drawRightString>
<drawString x="1.3cm" y="24.6cm">Mail:</drawString>
<drawRightString x="7cm" y="24.6cm">[[ company.partner_id.email or '' ]]</drawRightString>
<lines>1.3cm 24.5cm 7cm 24.5cm</lines>
<!-- left margin -->
<rotate degrees="90"/>
<fill color="grey"/>
<drawString x="2.65cm" y="-0.4cm">generated by Odoo.com</drawString>
<fill color="black"/>
<rotate degrees="-90"/>
<!--page bottom-->
<lines>1.2cm 2.65cm 19.9cm 2.65cm</lines>
<place x="1.3cm" y="0cm" height="2.55cm" width="19.0cm">
<para style="main_footer">[[ company.rml_footer ]]</para>
<para style="main_footer">Contact : [[ user.name ]] - Page: <pageNumber/></para>
</place>
</pageGraphics>
</pageTemplate>
</header>
我更改了一些行以便打印 header 就像我需要的那样。当我按下按钮预览 Header/Footer 时,它会像我输入的那样显示所有内容,但是当我打印报告时我不起作用:header 仍然像默认情况一样打印。论坛中的一些帖子说取消选中“从附件重新加载”复选框...在我的情况下,它始终未选中。
如您所见,header 是用 RML 格式输入的,而我的报告是在 qWeb 中...这是一个问题吗?如果是,如何解决?
那么,如何编辑(...并让它工作...)默认的 PDF 报告 header???
提前致谢。
听说在Qweb中有两种不同的classes for set the custom header and Footer in div tag 可以直接将自定义header设置为header class in div 和页脚 class 设置为页脚 div tag.important 认为我们不会在您的视图文件中添加任何外部或内部页眉和页脚只需添加以下标签即可。
<div class="header">
<div class="row" style="border-bottom: 1px solid black;">
<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 t-field="company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' />
</div>
<div class="col-xs-5 pull-right" style="margin-top:5px;">
<t t-if="company.vat">
<b>GST ID :</b>
<span t-field="company.vat" /><br/>
</t>
<t t-if="company.phone">
<b>PHONE :</b>
<span t-field="company.phone" /><br/>
</t>
<t t-if="company.fax">
<b>FAX :</b>
<span t-field="company.fax" /><br/>
</t>
<t t-if="company.email">
<b>EMAIL :</b>
<span t-field="company.email" /><br/>
</t>
<t t-if="company.website">
<b>WEBSITE :</b>
<span t-field="company.website" />
</t>
</div>
</div>
</div>
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</div>
页眉和页脚 class 在 Qweb 中自动为该报告设置客户页眉和页脚。
我向您展示的代码在我这边运行良好。
希望这对您有所帮助..:)
要在 qweb
报告中定义您的自定义 header,方法是给 header class 到 div 选项卡,例如
<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>
<div class="footer">
<div class="row">
<!-- All your custom code here -->
</div>
</div>
</template>
我有一份 PDF 报告,使用 Odoo (v8) 中的 qWeb。我的报告有这行代码:
<t t-call="report.external_layout">
我想这一行是为了在 PDF 报告中插入预定义的 header。在 Settings -> Companies 中,相应公司的 Report Configuration 选项卡中,有如下内容:
<header>
<pageTemplate>
<frame id="first" x1="1.3cm" y1="3.0cm" height="21.7cm" width="19.0cm"/>
<stylesheet>
<!-- Set here the default font to use for all <para> tags -->
<paraStyle name='Normal' fontName="DejaVuSans"/>
<paraStyle name="main_footer" fontSize="8.0" alignment="CENTER"/>
<paraStyle name="main_header" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
</stylesheet>
<pageGraphics>
<!-- Set here the default font to use for all <drawString> tags -->
<setFont name="DejaVuSans" size="8"/>
<!-- You Logo - Change X,Y,Width and Height -->
<image x="1.3cm" y="27.7cm" height="40.0" >[[ company.logo or removeParentNode('image') ]]</image>
<fill color="black"/>
<stroke color="black"/>
<!-- page header -->
<lines>1.3cm 27.7cm 20cm 27.7cm</lines>
<drawRightString x="20cm" y="27.8cm">[[ company.rml_header1 ]]</drawRightString>
<drawString x="1.3cm" y="27.3cm">[[ company.partner_id.name ]]</drawString>
<place x="1.3cm" y="25.3cm" height="1.8cm" width="15.0cm">
<para style="main_header">[[ display_address(company.partner_id) or '' ]]</para>
</place>
<drawString x="1.3cm" y="25.0cm">Phone:</drawString>
<drawRightString x="7cm" y="25.0cm">[[ company.partner_id.phone or '' ]]</drawRightString>
<drawString x="1.3cm" y="24.6cm">Mail:</drawString>
<drawRightString x="7cm" y="24.6cm">[[ company.partner_id.email or '' ]]</drawRightString>
<lines>1.3cm 24.5cm 7cm 24.5cm</lines>
<!-- left margin -->
<rotate degrees="90"/>
<fill color="grey"/>
<drawString x="2.65cm" y="-0.4cm">generated by Odoo.com</drawString>
<fill color="black"/>
<rotate degrees="-90"/>
<!--page bottom-->
<lines>1.2cm 2.65cm 19.9cm 2.65cm</lines>
<place x="1.3cm" y="0cm" height="2.55cm" width="19.0cm">
<para style="main_footer">[[ company.rml_footer ]]</para>
<para style="main_footer">Contact : [[ user.name ]] - Page: <pageNumber/></para>
</place>
</pageGraphics>
</pageTemplate>
</header>
我更改了一些行以便打印 header 就像我需要的那样。当我按下按钮预览 Header/Footer 时,它会像我输入的那样显示所有内容,但是当我打印报告时我不起作用:header 仍然像默认情况一样打印。论坛中的一些帖子说取消选中“从附件重新加载”复选框...在我的情况下,它始终未选中。
如您所见,header 是用 RML 格式输入的,而我的报告是在 qWeb 中...这是一个问题吗?如果是,如何解决?
那么,如何编辑(...并让它工作...)默认的 PDF 报告 header???
提前致谢。
听说在Qweb中有两种不同的classes for set the custom header and Footer in div tag 可以直接将自定义header设置为header class in div 和页脚 class 设置为页脚 div tag.important 认为我们不会在您的视图文件中添加任何外部或内部页眉和页脚只需添加以下标签即可。
<div class="header">
<div class="row" style="border-bottom: 1px solid black;">
<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 t-field="company.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' />
</div>
<div class="col-xs-5 pull-right" style="margin-top:5px;">
<t t-if="company.vat">
<b>GST ID :</b>
<span t-field="company.vat" /><br/>
</t>
<t t-if="company.phone">
<b>PHONE :</b>
<span t-field="company.phone" /><br/>
</t>
<t t-if="company.fax">
<b>FAX :</b>
<span t-field="company.fax" /><br/>
</t>
<t t-if="company.email">
<b>EMAIL :</b>
<span t-field="company.email" /><br/>
</t>
<t t-if="company.website">
<b>WEBSITE :</b>
<span t-field="company.website" />
</t>
</div>
</div>
</div>
<div class="footer">
<div class="text-center" style="border-top: 1px solid black;">
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</div>
页眉和页脚 class 在 Qweb 中自动为该报告设置客户页眉和页脚。 我向您展示的代码在我这边运行良好。
希望这对您有所帮助..:)
要在 qweb
报告中定义您的自定义 header,方法是给 header class 到 div 选项卡,例如
<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>
<div class="footer">
<div class="row">
<!-- All your custom code here -->
</div>
</div>
</template>