本文整理匯總了Python中orders.models.Order.paid方法的典型用法代碼示例。如果您正苦於以下問題:Python Order.paid方法的具體用法?Python Order.paid怎麽用?Python Order.paid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類orders.models.Order
的用法示例。
在下文中一共展示了Order.paid方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: new_order
# 需要導入模塊: from orders.models import Order [as 別名]
# 或者: from orders.models.Order import paid [as 別名]
def new_order(request, pk):
template = 'pos/new_order.html'
form = OrderForm(request.POST or None)
if request.method == 'POST':
if form.is_valid():
table_order = Order.objects.filter(table=pk)
latest = table_order.latest('created')
if latest.paid == True:
order = Order()
else:
order = latest
order.number = Order.objects.count() + 1
order.table = Table.objects.get(number=pk)
order.paid = False
order.save()
orderitem = OrderItem()
product = form.cleaned_data.get('product')
orderitem.product = Product.objects.get(title=product)
orderitem.order = order
orderitem.table = Table.objects.get(number=pk)
orderitem.quantity = form.cleaned_data.get('quantity')
orderitem.total_price = orderitem.quantity * orderitem.product.unit_price
orderitem.discount = form.cleaned_data.get('discount')
orderitem.notes = form.cleaned_data.get('notes')
orderitem.save()
return redirect('/table/' + pk)
context = {'form': form}
return render(request, template, context)