Imrpoved addons path support
- added `get_report_resource` method in addons package - properly locate report resources bzr revid: ame@tinyerp.com-20080716133851-fy2be2nqpi3wdbzt
This commit is contained in:
parent
6c1e9c0627
commit
0b5bfd8020
|
@ -157,6 +157,15 @@ 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')
|
||||
"""
|
||||
|
||||
fname = os.path.join(os.path.dirname(ad), resource)
|
||||
if os.path.exists(fname):
|
||||
return fname
|
||||
return os.path.join(os.path.dirname(_ad), resource)
|
||||
|
||||
def get_modules():
|
||||
"""Returns the list of module names
|
||||
"""
|
||||
|
|
|
@ -37,6 +37,7 @@ import netsvc
|
|||
import pooler
|
||||
|
||||
import tools
|
||||
import addons
|
||||
import print_xml
|
||||
import render
|
||||
import urllib
|
||||
|
@ -121,7 +122,7 @@ class report_rml(report_int):
|
|||
pos_xml = i.end()
|
||||
|
||||
doc = print_xml.document(cr, uid, {}, {})
|
||||
tmpl_path = os.path.join(tools.config['root_path'], 'addons/custom/corporate_defaults.xml')
|
||||
tmpl_path = addons.get_report_resource('addons/custom/corporate_defaults.xml')
|
||||
doc.parse(tmpl_path, [uid], 'res.users', context)
|
||||
corporate_header = doc.xml_get()
|
||||
doc.close()
|
||||
|
@ -146,10 +147,8 @@ class report_rml(report_int):
|
|||
return xml
|
||||
|
||||
# load XSL (parse it to the XML level)
|
||||
styledoc = libxml2.parseDoc(tools.file_open(
|
||||
os.path.join(tools.config['root_path'], self.xsl)).read())
|
||||
xsl_path, tail = os.path.split(os.path.join(tools.config['root_path'],
|
||||
self.xsl))
|
||||
styledoc = libxml2.parseDoc(tools.file_open(addons.get_report_resource(self.xsl)).read())
|
||||
xsl_path, tail = os.path.split(addons.get_report_resource(self.xsl))
|
||||
for child in styledoc.children:
|
||||
if child.name == 'import':
|
||||
if child.hasProp('href'):
|
||||
|
|
Loading…
Reference in New Issue