From 6d73087d96ed82adf3517bdea1df82454189cfb6 Mon Sep 17 00:00:00 2001 From: xmo-odoo Date: Fri, 13 May 2016 17:28:19 +0200 Subject: [PATCH] [FIX] report: don't hide errors in custom reports If a custom report's render_html raises a KeyError for some reason, Report.get_html would swallow the exception and fallback on generic HTML rendering, usually blowing up with unfathomable errors of missing rendering context data. Check if a custom report object exists instead of waiting for a KeyError. --- addons/report/models/report.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/report/models/report.py b/addons/report/models/report.py index 8c06712f797..7f25a308df9 100644 --- a/addons/report/models/report.py +++ b/addons/report/models/report.py @@ -115,11 +115,11 @@ class Report(osv.Model): """ # If the report is using a custom model to render its html, we must use it. # Otherwise, fallback on the generic html rendering. - try: - report_model_name = 'report.%s' % report_name - particularreport_obj = self.pool[report_model_name] + report_model_name = 'report.%s' % report_name + particularreport_obj = self.pool.get(report_model_name) + if particularreport_obj is not None: return particularreport_obj.render_html(cr, uid, ids, data=data, context=context) - except KeyError: + else: report = self._get_report_from_name(cr, uid, report_name) report_obj = self.pool[report.model] docs = report_obj.browse(cr, uid, ids, context=context)