Fix report_sxw for auto load report
authorced <>
Mon, 8 Oct 2007 11:30:27 +0000 (11:30 +0000)
committerced <>
Mon, 8 Oct 2007 11:30:27 +0000 (11:30 +0000)
bzr revid: ced-290abbeb2c9affb44e7559c5d0e55f430caa983f

bin/report/report_sxw.py

index 192b0a7..fc0b720 100644 (file)
@@ -341,10 +341,13 @@ class report_sxw(report_rml):
                        context={}
                pool = pooler.get_pool(cr.dbname)
                ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')
-               report_xml_id = ir_actions_report_xml_obj.search(cr, uid,
-                               [('report_name', '=', self.name[7:])], context=context)[0]
-               rml = ir_actions_report_xml_obj.browse(cr, uid, report_xml_id,
-                               context=context).report_rml_content
+               report_xml_ids = ir_actions_report_xml_obj.search(cr, uid,
+                               [('report_name', '=', self.name[7:])], context=context)
+               if report_xml_ids:
+                       rml = ir_actions_report_xml_obj.browse(cr, uid, report_xml_ids[0],
+                                       context=context).report_rml_content
+               else:
+                       rml = tools.file_open(self.tmpl, subdir=None).read()
 
                rml_parser = self.parser(cr, uid, self.name2, context)
                objs = self.getObjects(cr, uid, ids, context)