页码 RML 测试

RML Test of Page Number

呜呜呜, 我在 Openerp 7 上工作,pdf 是用 rml 创建的。 问题是:我需要页码,但只是从第二页开始。 我尝试了一些 rml if 子句语句,但第 1 页一直被打印出来,而且打印出来的东西非常奇怪。

 <header>
    <pageTemplate id="second">

        <frame id="second" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>

        <pageGraphics>
            <image file="images/isatech_water_header_medium.jpg" x="0.0cm" y="24.4cm" width="19.0cm" height="6.0cm"/>
            <image file="images/isatech_water_footer.jpg" x="0.0cm" y="-0.5cm" width="16.9cm" height="2.6cm"/>
        </pageGraphics>

    </pageTemplate>

    <pageTemplate id="first">  

        <frame id="first" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>

        <pageGraphics>
            <image file="images/isatech_water_header.jpg" x="0.0cm" y="24.4cm" width="19.0cm" height="6.0cm"/>
            <image file="images/isatech_water_footer.jpg" x="0.0cm" y="-0.5cm" width="16.9cm" height="2.6cm"/>
            [[  <pageNumber/> != '1' and <drawCentredString x="10cm" y="0.3cm"><pageNumber/></drawCentredString> ]]
        </pageGraphics>

    </pageTemplate> 


</header>

pdf 上打印的内容是:

]] 1(2,3,...)

第二个 pageTemplate 用于在第 1 页之后打印不同的页眉。我希望在页码之后直接打印。

我真的不知道为什么代码会像他那样。也欢迎不同的解决方案。

制造克里斯

我找到了一种不同的方法。 检查 RML 中的 pageNumber 不是一个好主意。 如果我做对了,那么 pageNumber 将作为最后的步骤之一进行处理。 (对于 PageCount 也是如此,因为在构建文档结束之前您无法知道 pageCount) 即使您使用 pageNumber 调用 python 函数,它也会作为字符串处理。我可以想象这是同样的原因。 我帮助自己 <setNextTemplate name="pageTemplate id"/>

  1. 在设置 > 操作 > 报告 > "Your Report"
  2. 中取消选中添加 RML header
  3. 更改您的 RML 文件并定义不同的 pageTemplates

    <template title="Sales Order" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20" showBoundary="0">
    <pageTemplate id="first">
        <frame id="first" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>
        <pageGraphics>
            <image file="images/header_page_1.jpg" x="0.8cm" y="24.7cm" width="16,9cm" height="4cm"/>
            <image file="images/footer_page_1.jpg" x="0.4cm" y="-0.4cm" width="16.9cm" height="2.3cm"/>
        </pageGraphics>
    </pageTemplate>
    <pageTemplate id="second">
        <frame id="first" x1="2.2cm" y1="2.5cm" width="16.9cm" height="22.3cm"/>
        <pageGraphics>
            <image file="images/header_page_2.jpg" x="0.8cm" y="24.7cm" width="16,9cm" height="4cm"/>
            <image file="images/header_page_2.jpg" x="0.4cm" y="-0.4cm" width="16.9cm" height="2.3cm"/>
        </pageGraphics>
    </pageTemplate>
    

  4. 在第 x 页的某处添加 <setNextTemplate name="pageTemplate id"/> 或者<setNextTemplate name="pageTemplate id"/> <nextFrame/>改变第x+1页的pageTemplate

<setNextTemplate name="pageTemplate id"/>简单的定义了下一页的pageTemplate和 <nextFrame/>另外结束当前页面。

Edit(Multi-Company-Header): 我有点忘了我们有多个公司 Headers。我仍然使用这种方法。我只是为每家公司复制 .rml,并对不同的公司徽标进行硬编码。然后在每个公司(数据库)的报告设置页面中,我指定了正确的 .rml 文件。 我很多余,但我没有找到更好的解决方案。

VG 克里斯