Exemplo n.º 1
0
def listadoProductoEstadistico(request):

    detallesFacturas = DetalleFactura.objects.all()
    
    af = AdaptadorFactura()
    af.setDetalles(detallesFacturas)

    repos = relatorio.ReportRepository()
    basic = Template(source="", filepath=TEMPLATE_DIRS+'/estadisticaBase.ods')
    file(TEMPLATE_DIRS+'/estadistica.ods', 'wb').write(basic.generate(detalles=af.detalles).render().getvalue())        
    
    with open(TEMPLATE_DIRS+'/estadistica.ods', 'r') as odt:
        response = HttpResponse(odt.read(), mimetype='application/vnd.oasis.opendocument.text')
        response['Content-Disposition'] = 'inline;filename=Estadistica.ods'
        odt.close()
    return response
Exemplo n.º 2
0
def generarFactura(request):
    
    try:
        nroNota = request.GET.get("nroNota")
        notaVenta = NotaVenta.objects.get(pk = nroNota)
        af = AdaptadorFactura()
        af.inicializar(notaVenta)

        print "path = " + TEMPLATE_DIRS+'/facturaBase.odt'
        af.inicializar(notaVenta)
        repos = relatorio.ReportRepository()
        basic = Template(source="", filepath=TEMPLATE_DIRS+'/facturaBase.odt')

        file(TEMPLATE_DIRS+'/factura.odt', 'wb').write(basic.generate(factura=af, detalles=af.detalles).render().getvalue())        
        os.system('unoconv -f pdf '+TEMPLATE_DIRS+'/factura.odt')
        with open(TEMPLATE_DIRS+'/factura.pdf', 'r') as pdf:
            response = HttpResponse(pdf.read(), mimetype='application/pdf')
            response['Content-Disposition'] = 'inline;filename=some_file.pdf'
            pdf.close()
            return response

    except ObjectDoesNotExist:
        raise ErrorCobro()