=== modified file 'bin/report/interface.py' --- bin/report/interface.py 2009-12-02 07:30:41 +0000 +++ bin/report/interface.py 2010-04-08 13:49:35 +0000 @@ -32,7 +32,8 @@ import print_xml import render import urllib - +import base64 +import time # # encode a value to a string in utf8 and converts XML entities # @@ -93,9 +94,27 @@ pool = pooler.get_pool(cr.dbname) ir_actions_report_xml_obj = pool.get('ir.actions.report.xml') report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context) - self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report' + if report_xml_ids: + report_xml = ir_actions_report_xml_obj.browse(cr, uid, report_xml_ids[0], context=context) + report_type = report_xml.report_type + attach = report_xml.attachment + ir_actions_report_xml_obj_id = ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0] + self.title = report_xml_ids and ir_actions_report_xml_obj_id.name or 'OpenERP Report' create_doc = self.generators[report_type] pdf = create_doc(rml, title=self.title) + if self.xsl: + aname = eval(attach, {'object':ir_actions_report_xml_obj, 'time':time}) + pool = pooler.get_pool(cr.dbname) + name = aname + report_xml.report_type + for id in ids: + pool.get('ir.attachment').create(cr, uid, { + 'name': aname, + 'datas': base64.encodestring(pdf), + 'datas_fname': name, + 'res_model': self.table, + 'res_id': id, + }, context=context + ) return (pdf, report_type) def create_xml(self, cr, uid, ids, datas, context=None):