diff --git a/openerp/addons/base/res/res_company.py b/openerp/addons/base/res/res_company.py index 81b02360f6d..a16161c0e4a 100644 --- a/openerp/addons/base/res/res_company.py +++ b/openerp/addons/base/res/res_company.py @@ -307,36 +307,45 @@ class res_company(osv.osv): ] def preview_report(self, cr, uid, ids, context=None): - # Used new cursor as it was closed explicitly somewhere and because of this partner data was not printed - # Tocheck: its not closed - cr = pooler.get_db(cr.dbname).cursor() - company = self.browse(cr, uid, ids, context=context)[0] + #TODO: we should be able to create a report dynamically without using the filesystem (without using the trick with tempfilename) + if not ids: + return False + # we need to pass the company_id in order to make a new browse record for the rml parser, because the cursor was previously closed and because of this partner data was not printed + company_id = ids[0] + company = self.browse(cr, uid, company_id, context=context) class company_parser(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(company_parser, self).__init__(cr, uid, name, context=context) + import openerp + company = openerp.pooler.get_pool(cr.dbname).get('res.company').browse(cr, uid, company_id, context=context) self.setCompany(company) rml = etree.XML(company.rml_header) rml = rml.getchildren()[0] header_xml = """ -