如何更新PDF报告(qWeb)中的默认标题? [英] How to update default header in PDF report (qWeb)?

查看:57
本文介绍了如何更新PDF报告(qWeb)中的默认标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Odoo(v8)中的qWeb的PDF报告.我的报告包含以下代码行:

I have a PDF report, using qWeb in Odoo (v8). My report has this line of code:

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

我想这行是为了在PDF报告中插入预定义的标题.在设置"->公司"中,在相应公司的报告配置"标签中,有类似以下内容:

This line I suppose is for inserting the predefined header in the PDF report. In Settings -> Companies, tab Report Configuration in respective company, there is something like this:

<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>

我更改了一些行以打印标题,就像我需要它一样.当我按下预览页眉/页脚"按钮时,它会显示所有内容,就像我键入它一样,但是在打印报告时我无法正常工作:页眉仍像默认情况下一样被打印.论坛中的一些帖子说取消选中从附件重新加载"复选框...就我而言,它始终未被选中.

I changed some lines in order to print the header just like I need it. When I press button Preview Header/Footer, it shows everything just like I typed it, but I doesn't work when I print the report: header is still printed like it was by default. Some threads in forums say to uncheck the Reload from Attachment checkbox... in my case, it always has been unchecked.

如您所见,标头以RML​​格式键入,而我的报告在qWeb中...这是问题吗?如果是,该如何解决?

As you can see, header is typed in RML form, and my report is in qWeb... Is this a problem? If it is it, how to fix it?

因此,如何编辑(...并使之工作...)PDF报告默认标题?

So, how to edit (... and make it to work ...) the PDF report default header???

谢谢.

推荐答案

要在qweb报告中定义自定义标题,方法是将标题类提供给div标签,例如

To define your custom header in qweb report by giving a header class to div tab like

<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报告(qWeb)中的默认标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆