I have created a wizard in my module that generate static Excel report, it works well. The problem is that there are clients who access my module remotely, when they open wizard and click on button the generated report saves on my local drive and they get nothing, is there any solution that I make my XLSX report as a downloadable file and the clients can download it directly ?
This is what I have tried but it didn't work:
data = wizard.plugin_file
file_path = wizard.file_path
my_report_data = open('C:/Users/Report.xlsx','rb')
f = my_report_data.read()
output = base64.encodestring(f)
self.write(cr, uid, ids[0], {'plugin_file': output}, context = context)
view_obj = self.pool.get('ir.ui.view')
view_id = view_obj.search(cr, uid, [('model', '=', 'report.model'), \
('name', '=', 'report_model_form_view2')])
return {
'name': 'Monthly Report ',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'report.model',
'view_id': view_id, 'form'
'res_id': ids[0],
'type': 'ir.actions.act_window',
'target': 'new',
'context': context,
}
Form:
<field name="file_path" invisible="1"/>
<field name="plugin_file" filename="file_path"/>