[FIX] ir_actions: adapt render_report when called in a tests/qweb report context...
authorSimon Lejeune <sle@openerp.com>
Wed, 21 May 2014 11:11:27 +0000 (13:11 +0200)
committerSimon Lejeune <sle@openerp.com>
Wed, 21 May 2014 11:11:27 +0000 (13:11 +0200)
openerp/addons/base/ir/ir_actions.py
openerp/tools/test_reports.py

index 4e17795..8aa968a 100644 (file)
@@ -41,6 +41,7 @@ import openerp.workflow
 
 _logger = logging.getLogger(__name__)
 
+
 class actions(osv.osv):
     _name = 'ir.actions.actions'
     _table = 'ir_actions'
@@ -129,9 +130,15 @@ class ir_actions_report_xml(osv.osv):
         Look up a report definition and render the report for the provided IDs.
         """
         new_report = self._lookup_report(cr, name)
-        # in order to use current yml test files with qweb reports
-        if isinstance(new_report, (str, unicode)):
-            return self.pool['report'].get_pdf(cr, uid, res_ids, new_report, data=data, context=context), 'pdf'
+
+        if isinstance(new_report, (str, unicode)):  # Qweb report
+            # The only case where a QWeb report is rendered with this method occurs when running
+            # yml tests originally written for RML reports.
+            if openerp.tools.config['test_enable'] and not tools.config['test_report_directory']:
+                # Only generate the pdf when a destination folder has been provided.
+                return self.pool['report'].get_html(cr, uid, res_ids, new_report, data=data, context=context), 'html'
+            else:
+                return self.pool['report'].get_pdf(cr, uid, res_ids, new_report, data=data, context=context), 'pdf'
         else:
             return new_report.create(cr, uid, res_ids, data, context)
 
@@ -1170,7 +1177,4 @@ class ir_actions_act_client(osv.osv):
 
     }
 
-
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
index c008c20..305d2b0 100644 (file)
@@ -87,8 +87,7 @@ def try_report(cr, uid, rname, ids, data=None, context=None, our_module=None, re
                 if ('[[' in line) or ('[ [' in line):
                     _logger.error("Report %s may have bad expression near: \"%s\".", rname, line[80:])
             # TODO more checks, what else can be a sign of a faulty report?
-    elif res_format == 'foobar':
-        # TODO
+    elif res_format == 'html':
         pass
     else:
         _logger.warning("Report %s produced a \"%s\" chunk, cannot examine it", rname, res_format)