Fix relative path in report and module xml
bzr revid: ced-96fb1d71e2b7282f46324766dd733aa1181e9e00
This commit is contained in:
parent
62c844b840
commit
c378996c51
|
@ -142,6 +142,14 @@ class report_rml(report_int):
|
|||
# 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))
|
||||
for child in styledoc.children:
|
||||
if child.name == 'import':
|
||||
if child.hasProp('href'):
|
||||
file = child.prop('href')
|
||||
child.setProp('href', str(
|
||||
os.path.normpath(os.path.join(xsl_path, file))))
|
||||
|
||||
#TODO: get all the translation in one query. That means we have to:
|
||||
# * build a list of items to translate,
|
||||
|
@ -153,7 +161,8 @@ class report_rml(report_int):
|
|||
while child is not None:
|
||||
if (child.type == "element") and child.hasProp('t'):
|
||||
#FIXME: use cursor
|
||||
res = service.execute(cr.dbname, uid, 'ir.translation', '_get_source', self.name2, 'xsl', lang, child.content)
|
||||
res = service.execute(cr.dbname, uid, 'ir.translation',
|
||||
'_get_source', self.name2, 'xsl', lang, child.content)
|
||||
if res:
|
||||
child.setContent(res)
|
||||
look_down(child.children, lang)
|
||||
|
@ -162,11 +171,14 @@ class report_rml(report_int):
|
|||
if context.get('lang', False):
|
||||
look_down(styledoc.children, context['lang'])
|
||||
|
||||
style = libxslt.parseStylesheetDoc(styledoc) # parse XSL
|
||||
|
||||
doc = libxml2.parseMemory(xml,len(xml)) # load XML (data)
|
||||
result = style.applyStylesheet(doc, None) # create RML (apply XSL to XML data)
|
||||
xml = style.saveResultToString(result) # save result to string
|
||||
# parse XSL
|
||||
style = libxslt.parseStylesheetDoc(styledoc)
|
||||
# load XML (data)
|
||||
doc = libxml2.parseMemory(xml,len(xml))
|
||||
# create RML (apply XSL to XML data)
|
||||
result = style.applyStylesheet(doc, None)
|
||||
# save result to string
|
||||
xml = style.saveResultToString(result)
|
||||
|
||||
style.freeStylesheet()
|
||||
doc.freeDoc()
|
||||
|
|
|
@ -353,7 +353,9 @@ class document(object):
|
|||
if not context:
|
||||
context={}
|
||||
# parses the xml template to memory
|
||||
self.dom = minidom.parse(os.path.join(tools.config['root_path'],filename))
|
||||
self.dom = minidom.parseString(tools.file_open(
|
||||
os.path.join(tools.config['root_path'],
|
||||
filename)).read())
|
||||
|
||||
# create the xml data from the xml template
|
||||
self.parse_tree(ids, model, context)
|
||||
|
|
|
@ -181,6 +181,7 @@ def file_open(name, mode="r", subdir='addons'):
|
|||
# Check for a zipfile in the path
|
||||
head = name
|
||||
zipname = False
|
||||
name2 = False
|
||||
while True:
|
||||
head, tail = os.path.split(head)
|
||||
if not tail:
|
||||
|
@ -197,9 +198,11 @@ def file_open(name, mode="r", subdir='addons'):
|
|||
os.path.basename(head), zipname).replace(
|
||||
os.sep, '/')))
|
||||
except:
|
||||
name2 = os.path.normpath(os.path.join(head + '.zip', zipname))
|
||||
pass
|
||||
if os.path.isfile(name):
|
||||
return file(name, mode)
|
||||
for i in (name2, name):
|
||||
if i and os.path.isfile(i):
|
||||
return file(i, mode)
|
||||
|
||||
raise IOError, 'File not found : '+str(name)
|
||||
|
||||
|
|
Loading…
Reference in New Issue