I'm trying to export some records in csv file.
function export_accounts() will call from button in wizard and the file download perfectly. but the wizard doesn't close automatically.
@api.multi
def export_accounts(self):
context = dict(self._context or {})
active_ids = context.get('active_ids', []) or []
data = self.env['export.csv.file'].csv_accounts(active_ids)
data = base64.encodestring(data)
attachment = {'name': 'Export Account Information',
'datas': data,
'datas_fname': 'accounts_export.csv',
'res_model': 'trans.export.csv',
'res_id': self.id}
attachment_id = self.env['ir.attachment'].create(attachment)
return {
'type': 'ir.actions.act_url',
'url': "web/content/?model=ir.attachment&id=" + str(attachment_id.id) +
"&filename=accounts_export.csv&field=datas&download=true&filename=" + attachment_id.datas_fname,
'target': 'self',
}