Make an xls file downloadable in Python

0

I would like you to help me know; How can I get the file I am generating downloaded? That is, I click on a button that executes the function and creates a file .XLS (for a spreadsheet) but the user who clicks, at no time knows where that file is saved. I would like the file to be downloaded automatically, look for examples and I can not fully understand, could you help me? Thank you in advance.

# -*- coding: utf-8 -*-

from openerp.osv import osv, fields
from xlwt import Workbook
from xlwt import Formula
from urllib2 import urlopen
import os
from urllib import urlretrieve, urlcleanup


class wizard_reportes_excel(osv.osv_memory):
    _name='wizard.reportes.excel'
    _description='wizard reportes excel'


    _columns={
        'estacion': fields.many2one('res.branch',string='Estacion'),
        'fecha_inicio': fields.date(string='Fecha inicio'),
        'fecha_fin': fields.date(string='Fecha fin'),
        'ventas_estacion': fields.boolean(string='Ventas por Estacion')
    }


    def export_report(self, cr, uid, ids, context=None):


        libro = Workbook()
        libro1 = libro.add_sheet("Ingresos")
        libro1.write(0, 0, 'DATO PARA LA PRUEBA')

        libro.save("PRUEBA REPORTE.xls")

        print('TERMINO EL PROCESO...')
        return 
    
asked by Gustavo Hernandez 31.07.2018 в 18:03
source

0 answers