[FIX] utf8 debug + minial bin version

bzr revid: nicolas.bessi@camptocamp.com-20110322134203-vsn3rsx13mg9u5vx
This commit is contained in:
nicolas.bessi@camptocamp.com 2011-03-22 14:42:03 +01:00
commit e790b28eba
3 changed files with 22 additions and 9 deletions

View File

@ -53,7 +53,7 @@
<body style="border:0; margin: 0;" onload="subst()">
<table class="header" style="border-bottom: 0px solid black; width: 100%">
<tr>
<td>${helper.embed_logo_by_name('camptocamp_logo')}</td>
<td>${helper.embed_logo_by_name('camptocamp_logo')|n}</td>
<td style="text-align:right"> </td>
</tr>
<tr>
@ -75,7 +75,7 @@
<tr>
<td>Mail: ${company.partner_id.address and company.partner_id.address[0].email or ''|entity}<br/></td>
</tr>
</table> ${_debug or ''} </body>
</table> ${_debug or ''|n} </body>
</html>]]>
</field>
<field eval="55.0" name="margin_top"/>

View File

@ -48,7 +48,7 @@ class WebKitHelper(object):
else :
width = ' '
if height :
height = 'width="%spx"'%(height)
height = 'height="%spx"'%(height)
else :
height = ' '
toreturn = '<img %s %s src="data:image/%s;base64,%s" />'%(

View File

@ -44,6 +44,16 @@ import addons
from tools.translate import _
from osv.osv import except_osv
def mako_template(text):
"""Build a Mako template.
This template uses UTF-8 encoding
"""
# default_filters=['unicode', 'h'] can be used to set global filters
return Template(text, input_encoding='utf-8', output_encoding='utf-8')
class WebKitParser(report_sxw):
"""Custom class that use webkit to render HTML reports
Code partially taken from report openoffice. Thanks guys :)
@ -67,7 +77,8 @@ class WebKitParser(report_sxw):
_('Please install executable on your system'+
' (sudo apt-get install wkhtmltopdf) or download it from here:'+
' http://code.google.com/p/wkhtmltopdf/downloads/list and set the'+
' path to the executable on the Company form.')
' path to the executable on the Company form.'+
'Minimal version is 0.9.9')
)
if os.path.isabs(path) :
if (os.path.exists(path) and os.access(path, os.X_OK)\
@ -98,7 +109,9 @@ class WebKitParser(report_sxw):
else:
command = ['wkhtmltopdf']
command.append('-q')
command.append('--quiet')
# default to UTF-8 encoding. Use <meta charset="latin-1"> to override.
command.append("--encoding 'utf-8'")
if header :
head_file = file( os.path.join(
tmp_dir,
@ -276,7 +289,7 @@ class WebKitParser(report_sxw):
company= user.company_id
#default_filters=['unicode', 'entity'] can be used to set global filter
body_mako_tpl = Template(template ,input_encoding='utf-8')
body_mako_tpl = mako_template(template)
helper = WebKitHelper(cursor, uid, report_xml.id, context)
try :
html = body_mako_tpl.render( helper=helper,
@ -288,7 +301,7 @@ class WebKitParser(report_sxw):
msg = exceptions.text_error_template().render()
netsvc.Logger().notifyChannel('Webkit render', netsvc.LOG_ERROR, msg)
raise except_osv(_('Webkit render'), msg)
head_mako_tpl = Template(header, input_encoding='utf-8')
head_mako_tpl = mako_template(header)
try :
head = head_mako_tpl.render(
company=company,
@ -305,7 +318,7 @@ class WebKitParser(report_sxw):
exceptions.text_error_template().render())
foot = False
if footer :
foot_mako_tpl = Template(footer ,input_encoding='utf-8')
foot_mako_tpl = mako_template(footer)
try :
foot = foot_mako_tpl.render(
company=company,
@ -327,7 +340,7 @@ class WebKitParser(report_sxw):
time=time,
helper=helper,
css=css,
_debug=html,
_debug=html.decode(),
formatLang=self.formatLang,
setLang=self.setLang,
_=self.translate_call,