本文整理汇总了Python中models.Customer.base_discount方法的典型用法代码示例。如果您正苦于以下问题:Python Customer.base_discount方法的具体用法?Python Customer.base_discount怎么用?Python Customer.base_discount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Customer
的用法示例。
在下文中一共展示了Customer.base_discount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addCustomer
# 需要导入模块: from models import Customer [as 别名]
# 或者: from models.Customer import base_discount [as 别名]
def addCustomer():
form = AddCustomerForm()
form.recommender.choices = [(0, '')]
poss_customers = Customer.query\
.filter(Customer.customer_type == CUSTOMER_TYPES['TYPE_CUSTOMER']).all()
for cust in poss_customers:
form.recommender.choices.append((cust.id, cust.name))
if form.validate_on_submit():
customer = Customer()
customer.name = form.name.data
customer.email = form.email.data
customer.base_discount = int(form.base_discount.data)/100.0
if form.recommender.data and form.recommender.data > 0:
customer.recommender_id = form.recommender.data
customer.company_name = form.company_name.data
if form.post_code1.data and form.post_code2.data:
customer.post_code = int(str(form.post_code1.data) + str(form.post_code2.data))
else:
customer.post_code = None
customer.address1 = form.address1.data
customer.address2 = form.address2.data
customer.address3 = form.address3.data
db.session.add(customer)
db.session.commit()
flash(gettext("New customer successfully added."))
return redirect(url_for("customers"))
return render_template('settings/addCustomer.html',
title=gettext("Add New Customer"),
form=form)