1 ##############################################################################
3 # Copyright (c) 2004-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
4 # Fabien Pinckaers <fp@tiny.Be>
6 # WARNING: This program as such is intended to be used by professional
7 # programmers who take the whole responsability of assessing all potential
8 # consequences resulting from its eventual inadequacies and bugs
9 # End users who are looking for a ready-to-use solution with commercial
10 # garantees and support are strongly adviced to contract a Free Software
13 # This program is Free Software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License
15 # as published by the Free Software Foundation; either version 2
16 # of the License, or (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ##############################################################################
29 from osv import fields,osv
30 from wizard.tiny_sxw2rml import sxw2rml
31 from StringIO import StringIO
32 from report import interface
37 class report_xml(osv.osv):
38 _inherit = 'ir.actions.report.xml'
40 def sxwtorml(self,cr, uid, file_sxw):
42 The use of this function is to get rml file from sxw file.
44 sxwval = StringIO(base64.decodestring(file_sxw))
45 fp = tools.file_open('normalized_oo2rml.xsl',
46 subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
47 return {'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read()))}
49 def upload_report(self, cr, uid, report_id, file_sxw, context):
53 pool = pooler.get_pool(cr.dbname)
54 sxwval = StringIO(base64.decodestring(file_sxw))
55 fp = tools.file_open('normalized_oo2rml.xsl',
56 subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
57 report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], {
58 'report_sxw_content': base64.decodestring(file_sxw),
59 'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read()))
62 db = pooler.get_db_only(cr.dbname)
63 interface.register_all(db)
65 def report_get(self, cr, uid, report_id, context={}):
66 report = self.browse(cr, uid, report_id, context)
68 'report_sxw_content': report.report_sxw_content and base64.encodestring(report.report_sxw_content) or False,
69 'report_rml_content': report.report_rml_content and base64.encodestring(report.report_rml_content) or False