本文整理汇总了Python中models.Order.supplier方法的典型用法代码示例。如果您正苦于以下问题:Python Order.supplier方法的具体用法?Python Order.supplier怎么用?Python Order.supplier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Order
的用法示例。
在下文中一共展示了Order.supplier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: place_order_ajax
# 需要导入模块: from models import Order [as 别名]
# 或者: from models.Order import supplier [as 别名]
def place_order_ajax(request):
"""
Create a new order
"""
returnDict = {}
if request.method == 'POST':
try:
#First raise the order as we'll need it for the second part :)
order_dict = json.loads(request.POST['datadict'])
order = Order()
order.supplier = Supplier.objects.filter(id=order_dict['supplier']).get()
if order_dict['account'] == "none":
order.account = None
else:
order.account = SupplierAccount.objects.filter(id=order_dict['account']).get()
order.expected_delivery = datetime.datetime.strptime(order_dict['expected_delivery'], "%m/%d/%Y")
order.date_placed = datetime.datetime.now()
order.save()
returnDict['order'] = order.id
#now add the parts in
parts_list = []
for part in order_dict['parts']:
orderpart = PartsToOrder()
orderpart.order = order
orderpart.part = Part.objects.filter(number=part['part_number']).get()
orderpart.quantity = float(part['quantity'])
orderpart.save()
parts_list.append(orderpart.id)
returnDict['parts_list'] = parts_list
except Exception, e:
print e
returnDict['error'] = e.message