rendering mako template to html to generate a report will fail

Bug #1280988 reported by joeshen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

In makohtml2html.py

    def format_body(self, html):
        body = html.findall('body')
        body_list = []
        footer = self.format_footer(body[-1].getchildren())
        for b in body[:-1]:
            body_list.append(etree.tostring(b).replace('\t', '').replace('\n',''))

【Description above in English 】
Here, because for a html file, it should be only have 1 body tag, so in for loop statement, body[:-1] will return a null list.

I think, this way of parsing mako template parser is wrong. and it needs a better parsing method.

while my mako templates as below,

# -*- coding: utf-8 -*-
<html>

% for o in objects:
<body>
 <table>number: 1
 </table>
</body>
% endfor

 </html>

there always report a Error:

2014-02-17 15:32:15,246 4228 ERROR openerp.report.render.makohtml2html.makohtml2html: report :
Traceback (most recent call last):
  File "D:\openerp-7.0-20131203-002409\openerp\report\render\makohtml2html\makohtml2html.py", line 126, in render
    final_html += self.format_body(etree_obj)
  File "D:\openerp-7.0-20131203-002409\openerp\report\render\makohtml2html\makohtml2html.py", line 51, in format_body
    footer = self.format_footer(body[-1].getchildren())
  File "D:\openerp-7.0-20131203-002409\openerp\report\render\makohtml2html\makohtml2html.py", line 44, in format_footer
    for node in footer[0].getchildren():
IndexError: list index out of range
2014-02-17 15:32:15,250 4228 ERROR openerp.netsvc: RML is not available at specified location or not enough data to print!
(None, None, None)

but if add "head" and another "body" with "footer", above error will disappear, but for a html file, multi "body" tag is fault, too.

# -*- coding: utf-8 -*-
<html>
<head>

</head>
% for o in objects:
<body>
 <table>number: 1
 </table>
</body>
% endfor
<body>
 <footer></footer>
</body>
 </html>

So please help me to clear it.
thx.

Tags: mako report
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.