reports.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:tambox 作者: joseamaya 项目源码 文件源码
def tabla_detalle(self):
        orden = self.orden_compra
        encabezados = ['Item', 'Cantidad', 'Unidad', u'Descripción','Precio','Total']
        detalles = DetalleOrdenCompra.objects.filter(orden=orden).order_by('pk')
        sp = ParagraphStyle('parrafos')
        sp.alignment = TA_JUSTIFY 
        sp.fontSize = 8
        sp.fontName="Times-Roman"        
        lista_detalles = []
        for detalle in detalles:
            try:
                tupla_producto = [Paragraph(str(detalle.nro_detalle),sp), 
                                  Paragraph(str(detalle.cantidad), sp),
                                  Paragraph(detalle.detalle_cotizacion.detalle_requerimiento.producto.unidad_medida.descripcion,sp),
                                  Paragraph(detalle.detalle_cotizacion.detalle_requerimiento.producto.descripcion, sp),
                                  Paragraph(str(detalle.precio),sp),
                                  Paragraph(str(detalle.valor),sp)]
            except:
                tupla_producto = [Paragraph(str(detalle.nro_detalle),sp), 
                                  Paragraph(str(detalle.cantidad), sp),
                                  Paragraph(detalle.producto.unidad_medida.descripcion,sp),
                                  Paragraph(detalle.producto.descripcion, sp),
                                  Paragraph(str(detalle.precio),sp),
                                  Paragraph(str(detalle.valor),sp)]
            lista_detalles.append(tupla_producto)
        adicionales = [('','','','','')] * (15-len(lista_detalles))
        tabla_detalle = Table([encabezados] + lista_detalles + adicionales,colWidths=[0.8 * cm, 2 * cm, 2.5 * cm,10.2* cm, 2 * cm, 2.5 * cm])
        style = TableStyle(
            [
                ('ALIGN',(0,0),(4,0),'CENTER'),
                ('GRID', (0, 0), (-1, -1), 1, colors.black),
                ('FONTSIZE', (0, 0), (-1, -1), 7),  
                ('ALIGN',(4,1),(-1,-1),'LEFT'), 
                ('VALIGN',(0,0),(-1,-1),'TOP'),          
            ]
        )
        tabla_detalle.setStyle(style)
        return tabla_detalle
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号