Merge remote-tracking branch 'odoo/7.0' into 7.0
authorOCA git bot <OCA-git-bot@therp.nl>
Tue, 21 Oct 2014 21:42:37 +0000 (23:42 +0200)
committerOCA git bot <OCA-git-bot@therp.nl>
Tue, 21 Oct 2014 21:42:37 +0000 (23:42 +0200)
1  2 
openerp/report/render/rml2pdf/trml2pdf.py

@@@ -88,7 -88,6 +88,6 @@@ class NumberedCanvas(canvas.Canvas)
          self._saved_page_states = []
  
      def showPage(self):
-         self._saved_page_states.append(dict(self.__dict__))
          self._startPage()
  
      def save(self):
@@@ -123,6 -122,8 +122,8 @@@ class PageCount(platypus.Flowable)
  
  class PageReset(platypus.Flowable):
      def draw(self):
+         """Flag to close current story page numbering and prepare for the next
+         should be executed after the rendering of the full story"""
          self.canv._doPageReset = True
  
  class _rml_styles(object,):
@@@ -766,17 -767,8 +767,17 @@@ class _rml_flowable(object)
              if extra_style:
                  style.__dict__.update(extra_style)
              result = []
 -            for i in self._textual(node).split('\n'):
 -                result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
 +            textuals = self._textual(node).split('\n')
 +            keep_empty_lines = (len(textuals) > 1) and len(node.text.strip())
 +            for i in textuals:
 +                if keep_empty_lines and len(i.strip()) == 0:
 +                    i = '<font color="white">&nbsp;</font>'
 +                result.append(
 +                    platypus.Paragraph(
 +                        i, style, **(
 +                            utils.attr_get(node, [], {'bulletText':'str'}))
 +                    )
 +                )
              return result
          elif node.tag=='barCode':
              try:
@@@ -939,6 -931,9 +940,9 @@@ class TinyDocTemplate(platypus.BaseDocT
          self.handle_frameBegin()
  
      def afterPage(self):
+         if isinstance(self.canv, NumberedCanvas):
+             # save current page states before eventual reset
+             self.canv._saved_page_states.append(dict(self.canv.__dict__))
          if self.canv._doPageReset:
              # Following a <pageReset/> tag:
              # - we reset page number to 0
@@@ -1012,10 -1007,10 +1016,10 @@@ class _rml_template(object)
          story_cnt = 0
          for node_story in node_stories:
              if story_cnt > 0:
-                 # Reset Page Number with new story tag
-                 fis.append(PageReset())
                  fis.append(platypus.PageBreak())
              fis += r.render(node_story)
+             # end of story numbering computation
+             fis.append(PageReset())
              story_cnt += 1
          try:
              if self.localcontext and self.localcontext.get('internal_header',False):