Improved addons path support

- fixed `xsl:import` search problem (print report)

bzr revid: ame@tinyerp.com-20080716144301-x5ajq907yj2qogle
This commit is contained in:
Amit Mendapara
2008-07-16 20:13:01 +05:30
parent 0b5bfd8020
commit d90ead399a
2 changed files with 22 additions and 4 deletions
+21 -2
View File
@@ -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
+1 -2
View File
@@ -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,