【发布时间】:2015-03-13 14:41:58
【问题描述】:
我在我的模块中创建了一个生成静态 Excel 报告的向导,它运行良好。问题是有些客户远程访问我的模块,当他们打开向导并单击按钮时,生成的报告会保存在我的本地驱动器上,但他们什么也得不到,是否有任何解决方案可以将我的 XLSX 报告作为可下载文件和客户可以直接下载吗?
这是我尝试过的,但没有成功:
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,
}
表格:
<field name="file_path" invisible="1"/>
<field name="plugin_file" filename="file_path"/>
【问题讨论】:
标签: python python-3.x download odoo