Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db.models import Sum
- from customer_purchase_order.models import CustomerPurchaseOrder
- from customer_purchase_order.models import CustomerPurchaseOrderItem
- for ct in cts:
- cpos = CustomerPurchaseOrder.objects.filter(customer_team=ct, cancelled=False).distinct()
- total = cpos.count()
- for index, cpo in enumerate(cpos):
- CustomerPurchaseOrder.objects.filter(
- id=cpo.id,
- ).update(
- total_gross_value_on_file=CustomerPurchaseOrderItem.objects.filter(customer_purchase_order=cpo).distinct().aggregate(total_gross_value_on_file=Sum('total_gross_value_on_file')).get('total_gross_value_on_file'),
- )
- print u'completed {0}%'.format(((index+1) * 100) / total)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement