2016-01-07 21 views
0

Moin Moin, 我正在使用Openerp 7,並且使用rml創建了pdf。 問題是:我需要頁碼,但只是從第二頁開始。 我嘗試了一些rml if子句語句,但頁面1始終打印出來並且獲得printet的東西都非常奇怪。頁碼的RML測試

<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頁後印刷不同的頭我希望能在頁碼之後找到那條路。

我真的不知道爲什麼代碼的行爲就像他一樣。也歡迎不同的解決方案。

製造商Chris

回答

1

我發現了一個不同的方式來做到這一點。 檢查RML中的pageNumber並不是一個好主意。 如果我沒有弄錯,那麼pageNumber將作爲最後一個步驟處理。 (對於PageCount也是如此,因爲直到構建文檔結束時才能知道pageCount) 即使使用pageNumber調用python函數,它也會作爲String處理。我可以想象這是相同的原因。 我順手拿在設置>操作>報告> 「你的報告」

  • 更改您的RML文件和定義不同pageTemplates一個<setNextTemplate name="pageTemplate id"/>

    1. 選中Add RML頭

      <template title="Sales Order" author="OpenERP S.A.([email protected])" 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> 
      

    2. 第x頁的某處添加<setNextTemplate name="pageTemplate id"/><setNextTemplate name="pageTemplate id"/> <nextFrame/>更改頁面頁面X + 1

    <setNextTemplate name="pageTemplate id"/>的模板簡單地定義了下一頁的pageTemplate和 <nextFrame/> additionaly結束當前頁面。

    編輯(多公司標題):我有點忘了我們有多公司標題。我仍然使用這種方法。我只是複製每個公司的.rml文件,並對不同的公司徽標進行硬編碼。然後在每個公司(數據庫)的報告設置頁面中,指定正確的.rml文件。 我很冗餘,但我沒有找到更好的解決方案。

    VG Chris