Improved addons path support
- fixed `xsl:import` search problem (print report) bzr revid: ame@tinyerp.com-20080716144301-x5ajq907yj2qogle
This commit is contained in:
+21
-2
@@ -157,10 +157,29 @@ def get_module_resource(module, *args):
|
||||
"""
|
||||
return opj(get_module_path(module), *args)
|
||||
|
||||
def get_report_resource(resource):
|
||||
"""Return the full path of the given report resource (addons/hr/reports/timesheet.xsl')
|
||||
def get_report_resource(resource, base=None):
|
||||
"""Return the full path of the given report resource.
|
||||
|
||||
>>>
|
||||
>>> get_report_resource('addons/hr/reports/timesheet.xsl')
|
||||
>>> get_report_resource('../../base/reports/rml_template.xsl', '/path/to/addons/hr/reports')
|
||||
>>>
|
||||
"""
|
||||
|
||||
if base:
|
||||
# default location
|
||||
fname = os.path.normpath(os.path.join(base, resource))
|
||||
if os.path.exists(fname):
|
||||
return fname
|
||||
|
||||
# check in base location
|
||||
base = base.replace(ad, _ad)
|
||||
fname = os.path.normpath(os.path.join(base, resource))
|
||||
if os.path.exists(fname):
|
||||
return fname
|
||||
|
||||
assert os.path.exists(fname), 'File does not exist: %s' % fname
|
||||
|
||||
fname = os.path.join(os.path.dirname(ad), resource)
|
||||
if os.path.exists(fname):
|
||||
return fname
|
||||
|
||||
@@ -153,8 +153,7 @@ class report_rml(report_int):
|
||||
if child.name == 'import':
|
||||
if child.hasProp('href'):
|
||||
file = child.prop('href')
|
||||
child.setProp('href', urllib.quote(str(
|
||||
os.path.normpath(os.path.join(xsl_path, file)))))
|
||||
child.setProp('href', urllib.quote(str(addons.get_report_resource(file, base=xsl_path))))
|
||||
|
||||
#TODO: get all the translation in one query. That means we have to:
|
||||
# * build a list of items to translate,
|
||||
|
||||
Reference in New Issue
Block a user