Пример #1
0
 def additional_stuff(obj):
     obj.save()
     for i in set((i.split("/")[1] for i in request.POST if "/" in i)):
         count = request.POST["count/" + str(i)]
         each_cents = request.POST["each_cents/" + str(i)]
         product = request.POST["product/" + str(i)]
         if each_cents and count and int(each_cents) > 0 and int(count) > 0:
             if int(i) < 0:
                 order = Order(incoming_invoice=obj)
             else:
                 order = obj.order_set.get(pk=int(i))
             order.each_cents = each_cents
             order.product_id = product
             order.count = count
             order.save()
         elif int(i) >= 0:
             obj.order_set.get(pk=int(i)).delete()
     return True, ""