[FIX] report: page numbering rml reports
authorMartin Trigaux <mat@odoo.com>
Tue, 21 Oct 2014 08:54:23 +0000 (10:54 +0200)
committerMartin Trigaux <mat@odoo.com>
Tue, 21 Oct 2014 13:36:01 +0000 (15:36 +0200)
commit354b82bee050ed29dd96adad613cac79ca778104
tree816bf0988cd80b9187ddd12c008565cbb1bff8df
parent78a29b3738c14ccc8b042de1d95f502e4bc282ef
[FIX] report: page numbering rml reports

Save the NumberedCanvas state before doing a page reset.
The order of execution when rendering an rml report is the following:
1. init canevas (_pageNumber = 1)
2. render the page element
3. if still pages to render, afterPage method
4. if still pages to render, showPage method (_pageNumber += 1)
5. back to step 2 for each page
6. draw the ResetPage element (setting flag _doPageReset=True)
7. end the document build with afterPage & showPage method

The PageReset element should be executed at the end of the rendering of a story (subdocument) to reinitialize the page numbers to 0 (for new story) and insert the pageCount element for that story with the total number of pages (needed if want to use tag <pageCount/> in rml).

In case of NumberedCanvas (e.g. used in Trial Balance report), the numbering is generated at the end of the build using the _saved_page_states dict in the canevas.
To have an accurate _saved_page_states content, it needs to be saved before the pageReset.

Fixes #2225
openerp/report/render/rml2pdf/trml2pdf.py