def _upload_report(self, cr, uid, data, context):
     import tiny_sxw2rml
     import StringIO
     pool = pooler.get_pool(cr.dbname)
     sxwval = StringIO.StringIO(base64.decodestring(data['form']['file_sxw']))
     fp = tools.file_open('normalized_oo2rml.xsl',subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
     report = pool.get('ir.actions.report.xml').write(cr, uid, [data['form']['report_id']], {
         'report_sxw_content': base64.decodestring(data['form']['file_sxw']),
         'report_rml_content': str(tiny_sxw2rml.sxw2rml(sxwval, xsl=fp.read()))
     })
     return {}
Exemplo n.º 2
0
    def _save(self, cr, uid, data, context):
        pool = pooler.get_pool(cr.dbname)
        file_sxw = base64.decodestring(data['form']['datas'])
        sxwval = StringIO(file_sxw)
        debug(sxwval)
        file_type = 'sxw'
        if file_type == 'sxw':
            fp = open('D:/workspace/eMobility/wizard/tiny_sxw2rml/normalized_oo2rml.xsl','r')
        if file_type == 'odt':
            fp = tools.file_open('normalized_odt2rml.xsl',
                    subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
        xsl=fp.read()
        fp.close()
        report_content=str(sxw2rml(sxwval, xsl))
        fpp = open('D:/workspace/eMobility/report/test_report.rml','a+')
        fpp.write(report_content)
        debug(report_content)
        fpp.close()
        report_id=112
        report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], {
            'report_sxw_content': file_sxw,
            'report_rml_content': report_content,
            'report_type':'pdf'
        })
        cr.commit()
        db = pooler.get_db_only(cr.dbname)
        interface.register_all(db)
                                                      
#            'report_rml_content': report_content,})
#        report = pooler.get('ir.actions.report.xml').create(cr, uid, {
#            'auto':False,
#            'model':'cmc.assessment',
#            'type':'ir.actions.report.xml',
#            'report_name':'test.report',
#            'report_sxw_content': file_sxw,
#            'report_rml_content': report_content,
#            'report_rml':'eMobility/report/test_report.rml'
#        })
#        
#        cr.commit()
#        db = pooler.get_db_only(cr.dbname)
#        interface.register_all(db)
        data['form']['name']='CHECK HECKEC'
        debug(data)
        return data['form']