def upload_report(self, cr, uid, report_id, file_sxw, file_type, context): ''' Untested function ''' pool = pooler.get_pool(cr.dbname) sxwval = StringIO(base64.decodestring(file_sxw)) if file_type == 'sxw': fp = tools.file_open( 'normalized_oo2rml.xsl', subdir='addons/base_report_designer/wizard/tiny_sxw2rml') rml_content = str(sxw2rml(sxwval, xsl=fp.read())) if file_type == 'odt': fp = tools.file_open( 'normalized_odt2rml.xsl', subdir='addons/base_report_designer/wizard/tiny_sxw2rml') rml_content = str(sxw2rml(sxwval, xsl=fp.read())) if file_type == 'html': rml_content = base64.decodestring(file_sxw) report = pool.get('ir.actions.report.xml').write( cr, uid, [report_id], { 'report_sxw_content': base64.decodestring(file_sxw), 'report_rml_content': rml_content, }) cr.commit() db = pooler.get_db_only(cr.dbname) interface.register_all(db) return True
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']
def upload_report(self, cr, uid, report_id, file_sxw,file_type, context): ''' Untested function ''' pool = pooler.get_pool(cr.dbname) sxwval = StringIO(base64.decodestring(file_sxw)) if file_type=='sxw': fp = tools.file_open('normalized_oo2rml.xsl', subdir='addons/base_report_designer/wizard/tiny_sxw2rml') if file_type=='odt': fp = tools.file_open('normalized_odt2rml.xsl', subdir='addons/base_report_designer/wizard/tiny_sxw2rml') report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], { 'report_sxw_content': base64.decodestring(file_sxw), 'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())), }) cr.commit() db = pooler.get_db_only(cr.dbname) interface.register_all(db) return True