[MERGE] Forward-port of latest saas-2 bugfixes, up to rev. 9159 revid:dle@openerp.com-20140324104743-ubvu8st7emq9pg1q

bzr revid: dle@openerp.com-20140324110349-e82t1bmmtjqbl85k
This commit is contained in:
Denis Ledoux 2014-03-24 12:03:49 +01:00
commit f4b1d23cf2
3 changed files with 17 additions and 8 deletions

View File

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type"/>

View File

@ -112,6 +112,7 @@ def webkit_report_extender(report_name):
return fct
return fct1
class WebKitParser(report_sxw):
"""Custom class that use webkit to render HTML reports
Code partially taken from report openoffice. Thanks guys :)
@ -173,7 +174,7 @@ class WebKitParser(report_sxw):
),
'w'
)
head_file.write(header.encode('utf-8'))
head_file.write(self._sanitize_html(header.encode('utf-8')))
head_file.close()
file_to_del.append(head_file.name)
command.extend(['--header-html', head_file.name])
@ -184,7 +185,7 @@ class WebKitParser(report_sxw):
),
'w'
)
foot_file.write(footer.encode('utf-8'))
foot_file.write(self._sanitize_html(footer.encode('utf-8')))
foot_file.close()
file_to_del.append(foot_file.name)
command.extend(['--footer-html', foot_file.name])
@ -205,7 +206,7 @@ class WebKitParser(report_sxw):
for html in html_list :
html_file = file(os.path.join(tmp_dir, str(time.time()) + str(count) +'.body.html'), 'w')
count += 1
html_file.write(html.encode('utf-8'))
html_file.write(self._sanitize_html(html.encode('utf-8')))
html_file.close()
file_to_del.append(html_file.name)
command.append(html_file.name)
@ -366,7 +367,6 @@ class WebKitParser(report_sxw):
pdf = self.generate_pdf(bin, report_xml, head, foot, htmls)
return (pdf, 'pdf')
def create(self, cursor, uid, ids, data, context=None):
"""We override the create function in order to handle generator
Code taken from report openoffice. Thanks guys :) """
@ -387,11 +387,18 @@ class WebKitParser(report_sxw):
report_xml.report_sxw = None
else:
return super(WebKitParser, self).create(cursor, uid, ids, data, context)
if report_xml.report_type != 'webkit' :
if report_xml.report_type != 'webkit':
return super(WebKitParser, self).create(cursor, uid, ids, data, context)
result = self.create_source_pdf(cursor, uid, ids, data, report_xml, context)
if not result:
return (False,False)
return result
def _sanitize_html(self, html):
"""wkhtmltopdf expects the html page to declare a doctype.
"""
if html and html[:9].upper() != "<!DOCTYPE":
html = "<!DOCTYPE html>\n" + html
return html
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -55,11 +55,12 @@ class sale_make_invoice(osv.osv_memory):
raise osv.except_osv(_('Warning!'), _("You shouldn't manually invoice the following sale order %s") % (sale_order.name))
order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_invoice=data['invoice_date'])
for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context):
orders = order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context)
for o in orders:
for i in o.invoice_ids:
newinv.append(i.id)
# Dummy call to workflow, will not create another invoice but bind the new invoice to the subflow
order_obj.signal_manual_invoice(cr, uid, [o.id for o in orders if o.order_policy == 'manual'])
result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1')
id = result and result[1] or False
result = act_obj.read(cr, uid, [id], context=context)[0]