From ec9aceb72df15e5be7baceec8fb72747bfcc47bf Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 7 Dec 2012 18:46:32 +0100 Subject: [PATCH 1/2] [IMP] report_webkit: remove deprecated/unused lib_path for wkhtmltopdf Replaced by autodetection on system PATH + optional system config parameters via ir.config.parameter bzr revid: odo@openerp.com-20121207174632-xkizj5hf83aymgxe --- addons/report_webkit/company.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/addons/report_webkit/company.py b/addons/report_webkit/company.py index a8dc71f220f..f9ae4191528 100644 --- a/addons/report_webkit/company.py +++ b/addons/report_webkit/company.py @@ -29,9 +29,9 @@ # ############################################################################## -from osv import fields, osv +from openerp.osv import fields, osv -class ResCompany(osv.osv): +class res_company(osv.osv): """Override company to add Header object link a company can have many header and logos""" _inherit = "res.company" @@ -50,10 +50,6 @@ class ResCompany(osv.osv): 'html_id', 'Available html', ), - 'lib_path' : fields.char('Webkit Executable Path (Deprecated)', size=264, - help="This option is now deprecated in favor of autodetection of webkit location", - invisible=1), } -ResCompany() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From f5fd0fc0815190b3e80854a8ad0afa7a5d1271c4 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 7 Dec 2012 18:50:47 +0100 Subject: [PATCH 2/2] [FIX] report_webkit: fix incorrect usage of get_module_resource() As of 7.0 get_module_resource() enforces that its first argument should be a module name, followed by extra path components. + minimal lint cleanup bzr revid: odo@openerp.com-20121207175047-ghv0ic3auq8owt0t --- addons/l10n_ch/report/report_webkit_html.py | 16 ++++++---------- addons/report_webkit/webkit_report.py | 17 +++++++---------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/addons/l10n_ch/report/report_webkit_html.py b/addons/l10n_ch/report/report_webkit_html.py index 6b6a84e0cf4..9f650227313 100644 --- a/addons/l10n_ch/report/report_webkit_html.py +++ b/addons/l10n_ch/report/report_webkit_html.py @@ -20,7 +20,6 @@ ############################################################################## import time -import sys import os import re @@ -40,13 +39,10 @@ from tools import mod10r from tools.translate import _ from tools.config import config -import wizard -import addons +from openerp import addons import pooler - - class l10n_ch_report_webkit_html(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(l10n_ch_report_webkit_html, self).__init__(cr, uid, name, context=context) @@ -78,12 +74,12 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse): def police_absolute_path(self, inner_path): """Will get the ocrb police absolute path""" - path = addons.get_module_resource(os.path.join('l10n_ch', 'report', inner_path)) + path = addons.get_module_resource('l10n_ch', 'report', inner_path) return path def bvr_absolute_path(self) : """Will get the ocrb police absolute path""" - path = addons.get_module_resource(os.path.join('l10n_ch', 'report', 'bvr1.jpg')) + path = addons.get_module_resource('l10n_ch', 'report', 'bvr1.jpg') return path def headheight(self): @@ -167,7 +163,7 @@ class BVRWebKitParser(webkit_report.WebKitParser): """generate the PDF""" context = context or {} if report_xml.report_type != 'webkit': - return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context) + return super(BVRWebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context) self.parser_instance = self.parser(cursor, uid, self.name2, @@ -177,7 +173,7 @@ class BVRWebKitParser(webkit_report.WebKitParser): self.parser_instance.set_context(objs, data, ids, report_xml.report_type) template = False if report_xml.report_file : - path = addons.get_module_resource(report_xml.report_file) + path = addons.get_module_resource(*report_xml.report_file.split(os.path.sep)) if os.path.exists(path) : template = file(path).read() if not template and report_xml.report_webkit_data : @@ -203,7 +199,7 @@ class BVRWebKitParser(webkit_report.WebKitParser): company = user.company_id body_mako_tpl = mako_template(template) #BVR specific - bvr_path = addons.get_module_resource(os.path.join('l10n_ch','report','bvr.mako')) + bvr_path = addons.get_module_resource('l10n_ch','report','bvr.mako') body_bvr_tpl = mako_template(file(bvr_path).read()) helper = report_helper.WebKitHelper(cursor, uid, report_xml.id, context) ##BVR Specific diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index b03289c8748..eca33e1f941 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -106,7 +106,6 @@ class WebKitParser(report_sxw): webkit_header = report_xml.webkit_header tmp_dir = tempfile.gettempdir() out_filename = tempfile.mktemp(suffix=".pdf", prefix="webkit.tmp.") - files = [] file_to_del = [out_filename] if comm_path: command = [comm_path] @@ -220,7 +219,7 @@ class WebKitParser(report_sxw): template = False if report_xml.report_file : - path = addons.get_module_resource(report_xml.report_file) + path = addons.get_module_resource(*report_xml.report_file.split(os.path.sep)) if os.path.exists(path) : template = file(path).read() if not template and report_xml.report_webkit_data : @@ -242,8 +241,6 @@ class WebKitParser(report_sxw): css = report_xml.webkit_header.css if not css : css = '' - user = self.pool.get('res.users').browse(cursor, uid, uid) - company= user.company_id #default_filters=['unicode', 'entity'] can be used to set global filter body_mako_tpl = mako_template(template) @@ -257,7 +254,7 @@ class WebKitParser(report_sxw): _=self.translate_call, **self.parser_instance.localcontext) htmls.append(html) - except Exception, e: + except Exception: msg = exceptions.text_error_template().render() _logger.error(msg) raise except_osv(_('Webkit render!'), msg) @@ -268,7 +265,7 @@ class WebKitParser(report_sxw): _=self.translate_call, **self.parser_instance.localcontext) htmls.append(html) - except Exception, e: + except Exception: msg = exceptions.text_error_template().render() _logger.error(msg) raise except_osv(_('Webkit render!'), msg) @@ -279,7 +276,7 @@ class WebKitParser(report_sxw): _=self.translate_call, _debug=False, **self.parser_instance.localcontext) - except Exception, e: + except Exception: raise except_osv(_('Webkit render!'), exceptions.text_error_template().render()) foot = False @@ -301,7 +298,7 @@ class WebKitParser(report_sxw): _debug=tools.ustr("\n".join(htmls)), _=self.translate_call, **self.parser_instance.localcontext) - except Exception, e: + except Exception: msg = exceptions.text_error_template().render() _logger.error(msg) raise except_osv(_('Webkit render!'), msg) @@ -327,8 +324,8 @@ class WebKitParser(report_sxw): report_xml.report_rml = None report_xml.report_rml_content = None report_xml.report_sxw_content_data = None - report_rml.report_sxw_content = None - report_rml.report_sxw = None + report_xml.report_sxw_content = None + report_xml.report_sxw = None else: return super(WebKitParser, self).create(cursor, uid, ids, data, context) if report_xml.report_type != 'webkit' :