[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
This commit is contained in:
parent
ec9aceb72d
commit
f5fd0fc081
|
@ -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
|
||||
|
|
|
@ -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' :
|
||||
|
|
Loading…
Reference in New Issue