def update_order_list(request): order_id_list = request.POST.getlist('orderChecked') if not len(order_id_list) or "buttonSource" not in request.POST: return redirect('/cross_order/list_order/') action = request.POST['buttonSource'] if action == "status" and request.POST['statusUpdate'] is 0: return redirect('/cross_order/list_order/') if action == "inbound" and request.POST['inbound_order_number'] == "": return redirect('/cross_order/list_order/') if action == "comment" and request.POST['comment'] == "": return redirect('/cross_order/list_order/') if action == "status": cs = CrossStatus.objects.get(pk = request.POST['statusUpdate']) trans = Transactions() if cs.isTransactionGenerate: trans.code = generateTransactionString(Supplier.objects.get(pk=request.GET['sid']).name) trans.create_date = datetime.datetime.now() trans.create_user = request.user trans.status = TransactionStatus.objects.all().order_by("order")[0] trans.save() for oid in order_id_list: o = Order.objects.get(pk=oid) o.ordercrossdetails.cross_status = cs o.ordercrossdetails.save() lu = LastUpdate() lu.update_date = datetime.datetime.now() lu.cross_status = cs lu.order = o lu.user = request.user lu.save() if cs.isTransactionGenerate: o.ordercrossdetails.supplier_order_date = datetime.datetime.now() o.ordercrossdetails.save() OrderTransaction.objects.create(trans = trans,order = o) elif action == "inbound": ion = request.POST['inbound_order_number'] for oid in order_id_list: o = Order.objects.get(pk=oid) o.ordercrossdetails.inbound_order_number = ion o.ordercrossdetails.save() elif action == "comment": comment = request.POST['comment'] for oid in order_id_list: o = Order.objects.get(pk=oid) o.ordercrossdetails.comment = comment o.ordercrossdetails.save() sid = request.GET['sid'] dateStart = request.GET['dateStart'] dateEnd = request.GET['dateEnd'] return redirect('/cross_order/list_order/?sid='+sid+"&dateStart="+dateStart+"&dateEnd="+dateEnd+"&oattributeid="+request.GET['oattributeid'])
def update_trans_order_list(request): order_id_list = request.POST.getlist('orderChecked') if not len(order_id_list) or "buttonSource" not in request.POST: return redirect('/cross_order/transaction_details/'+request.GET['code']+'/') action = request.POST['buttonSource'] if action == "status" and request.POST['statusUpdate'] is 0: return redirect('/cross_order/transaction_details/'+request.GET['code']+'/') if action == "inbound" and request.POST['inbound_order_number'] == "": return redirect('/cross_order/transaction_details/'+request.GET['code']+'/') if action == "comment" and request.POST['comment'] == "": return redirect('/cross_order/transaction_details/'+request.GET['code']+'/') if action == "status": cs = CrossStatus.objects.get(pk = request.POST['statusUpdate']) if cs.isTransactionGenerate: return redirect('/cross_order/transaction_details/'+request.GET['code']+'/') for oid in order_id_list: o = Order.objects.get(pk=oid) o.ordercrossdetails.cross_status = cs o.ordercrossdetails.save() lu = LastUpdate() lu.update_date = datetime.datetime.now() lu.cross_status = cs lu.order = o lu.user = request.user lu.save() elif action == "inbound": ion = request.POST['inbound_order_number'] for oid in order_id_list: o = Order.objects.get(pk=oid) o.ordercrossdetails.inbound_order_number = ion o.ordercrossdetails.save() elif action == "comment": comment = request.POST['comment'] for oid in order_id_list: o = Order.objects.get(pk=oid) o.ordercrossdetails.comment = comment o.ordercrossdetails.save() return redirect('/cross_order/transaction_details/'+request.GET['code']+'/')
def fixSizes(): from main.models import OrderItemBase from main.models import Supplier from cross_order.models import OrderCrossDetails, CrossOrderItem from cross_order.models import LastUpdate, OrderTransaction for o in OrderCrossDetails.objects.all(): oib = OrderItemBase.objects.get(id_sales_order_item=o.order.id_sales_order_item) coi = CrossOrderItem() coi.orderitem = oib coi.order_attribute = o.order_attribute coi.cross_status = o.cross_status coi.supplier_order_date = o.supplier_order_date coi.comment = o.comment coi.inbound_order_number = o.inbound_order_number coi.save() for lu in o.order.lastupdateold_set.all(): item = LastUpdate() item.update_date = lu.update_date item.cross_status = lu.cross_status item.order = OrderItemBase.objects.get(id_sales_order_item=lu.order.id_sales_order_item) item.user = lu.user item.save() for ot in o.order.ordertransactionold_set.all(): item = OrderTransaction() item.trans = ot.trans item.order = OrderItemBase.objects.get(id_sales_order_item=ot.order.id_sales_order_item) item.save()