Beispiel #1
0
def procurement_orders(queryset):
    
    """
    Create a new Procurement
    """
    procurement = Procurement()
    procurement.save()

    """
    First, loop through the queryset and save the Orders
    to the ProcurementOrder model.
    """
    for order in queryset:
        procurement_order = ProcurementOrder(procurement=procurement, order=order)
        try:
            procurement_order.full_clean()
        except ValidationError, e:
            print u'*** ERROR %s' % e
            """
            Validation error is likely to be an Integrity Error
            due to the unique_together constraint on Procurement and Order
            
            TODO: assemble an error msg, and skip over the order.
            """
        else:
            procurement_order.save()
Beispiel #2
0
def procurement_orders(queryset, allow_closed_orders=False):
    """
    Create a new Procurement
    """
    procurement = Procurement()
    procurement.save()

    items = []

    """
    First, loop through the queryset and save the Orders
    to the ProcurementOrder model.
    """
    for order in queryset:
        if allow_closed_orders == False:
            if order.opened == False:
                import ipdb; ipdb.set_trace()
                continue

        procurement_order = ProcurementOrder(procurement=procurement, order=order)
        try:
            procurement_order.full_clean()
        except ValidationError, e:
            print u'*** ERROR %s' % e
            """
            Validation error is likely to be an Integrity Error
            due to the unique_together constraint on Procurement and Order

            TODO: assemble an error msg, and skip over the order.
            """
        else:
            procurement_order.save()
            print "Saved procurement order:", procurement_order
 def handle(self, *args, **options):
     """
     Reset first
     """
     procurement_orders = ProcurementOrder.objects.all()
     for procurement_order in procurement_orders:
         procurement_order.delete()
     
     procurements = Procurement.objects.all()
     for procurement in procurements:
         procurement.delete()
     
     """
     Create a new Procurement
     """
     procurement = Procurement()
     procurement.save()
 
     """
     First, loop through the queryset and save the Orders
     to the ProcurementOrder model.
     """
     queryset = Order.objects.all()
     
     # print '==== New Procurement ===='
     
     for order in queryset:
         
         # print u'Order: %s' % order
         
         procurement_order = ProcurementOrder(procurement=procurement, order=order)
         try:
             procurement_order.full_clean()
         except ValidationError, e:
             # print u'*** ERROR %s' % e
             pass
         else:
             procurement_order.save()
         
             """