本文整理匯總了Python中models.order.Order.add方法的典型用法代碼示例。如果您正苦於以下問題:Python Order.add方法的具體用法?Python Order.add怎麽用?Python Order.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.order.Order
的用法示例。
在下文中一共展示了Order.add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: index
# 需要導入模塊: from models.order import Order [as 別名]
# 或者: from models.order.Order import add [as 別名]
def index():
if not g.user.is_super_admin():
abort(403)
form = ClientOrderForm(request.form)
mediums = [(m.id, m.name) for m in Medium.all()]
if request.method == 'POST' and form.validate():
if ClientOrder.query.filter_by(contract=request.values.get('contract')).count() > 0:
flash(u'合同號已存在', 'danger')
return redirect(url_for('util_insert_orders.index'))
order = ClientOrder.add(agent=Agent.get(form.agent.data),
client=Client.get(form.client.data),
campaign=form.campaign.data,
money=int("%.0f" % (form.money.data or 0)),
client_start=form.client_start.data,
client_end=form.client_end.data,
reminde_date=form.reminde_date.data,
direct_sales=User.gets(form.direct_sales.data),
agent_sales=User.gets(form.agent_sales.data),
contract_type=form.contract_type.data,
resource_type=form.resource_type.data,
sale_type=form.sale_type.data,
contract=request.values.get('contract', ''),
creator=g.user,
contract_status=2,
create_time=datetime.now())
order.add_comment(g.user,
u"導入了客戶訂單:%s - %s - %s" % (
order.agent.name,
order.client.name,
order.campaign
))
medium_ids = request.values.getlist('medium')
medium_moneys = request.values.getlist('medium_money')
medium_moneys2 = request.values.getlist('medium_money2')
medium_contracts = request.values.getlist('medium_contract')
if medium_ids and medium_moneys and len(medium_ids) == len(medium_moneys):
for x in range(len(medium_ids)):
medium = Medium.get(medium_ids[x])
mo = Order.add(campaign=order.campaign,
medium=medium,
sale_money=int("%.0f" % (form.money.data or 0)),
medium_money=int(medium_moneys[x] or 0),
medium_money2=int(medium_moneys2[x] or 0),
medium_contract=medium_contracts[x],
medium_start=order.client_start,
medium_end=order.client_end,
creator=g.user)
order.medium_orders = order.medium_orders + [mo]
order.add_comment(g.user, u"導入了媒體訂單: %s %s元" %
(medium.name, mo.sale_money))
order.save()
flash(u'導入客戶訂單成功!', 'success')
insert_executive_report(order, '')
return redirect(order.info_path())
else:
form.client_start.data = datetime.now().date()
form.client_end.data = datetime.now().date()
form.reminde_date.data = datetime.now().date()
return tpl('insert_order.html', form=form, mediums=mediums)
示例2: add_order
# 需要導入模塊: from models.order import Order [as 別名]
# 或者: from models.order.Order import add [as 別名]
def add_order():
user = get_default_user()
medium = add_medium(TEST_MEDIUM)
order = Order.add(campaign='testcampaign', medium=medium, order_type=0,
creator=user, create_time=datetime.now())
return order