当前位置: 首页>>代码示例>>Python>>正文


Python Order.add方法代码示例

本文整理汇总了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)
开发者ID:giveme168,项目名称:braavos,代码行数:61,代码来源:insert_orders.py

示例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
开发者ID:giveme168,项目名称:braavos,代码行数:8,代码来源:helper.py


注:本文中的models.order.Order.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。