From d33f6f290323a0eaf259817e840a8a8b45e0bb27 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 16 Dec 2010 11:07:49 +0100 Subject: [PATCH] [FIX] report_sxw: workaround to prevent crash of reports launched from wizards that pass invalid IDs bzr revid: odo@openerp.com-20101216100749-z06fv08n4u5rhwl0 --- bin/report/report_sxw.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py index eb6fad169d6..fe04ca6b680 100644 --- a/bin/report/report_sxw.py +++ b/bin/report/report_sxw.py @@ -366,8 +366,10 @@ class rml_parse(object): else: self.localcontext.update({'name_space' :common.sxw_namespace}) + # WARNING: the object[0].exists() call below is slow but necessary because + # some broken reporting wizards pass incorrect IDs (e.g. ir.ui.menu ids) if objects and len(objects) == 1 and \ - 'company_id' in objects[0] and objects[0].company_id: + objects[0].exists() and 'company_id' in objects[0] and objects[0].company_id: # When we print only one record, we can auto-set the correct # company in the localcontext. For other cases the report # will have to call setCompany() inside the main repeatIn loop.