本文整理汇总了Python中models.Product.select方法的典型用法代码示例。如果您正苦于以下问题:Python Product.select方法的具体用法?Python Product.select怎么用?Python Product.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Product
的用法示例。
在下文中一共展示了Product.select方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_data_for
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def set_data_for(self, prod_find):
products = Product.select().order_by(Product.name.asc())
if prod_find:
products = products.where(Product.name.contains(prod_find))
self.data = [("", prod.name, "") for prod in products]
示例2: set_data_for
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def set_data_for(self, main_date):
try:
on, end = main_date.current.current
except:
on, end = main_date.current
on = datetime(on.year, on.month, on.day, 0, 0, 0)
end = datetime(end.year, end.month, end.day, 23, 59, 59)
reports = []
this_periode_rpt = Reports.select().where(Reports.date >= on,
Reports.date <= end)
for store in Store.select().order_by(Store.name):
if ([(i) for i in this_periode_rpt.where(Reports.store << [store, ])] == []):
continue
cpt = 0
for prod in Product.select().order_by(Product.name):
if ([(i) for i in this_periode_rpt.where(Reports.store == store,
Reports.product << [prod, ])] == []):
continue
dict_store = {}
repts = this_periode_rpt.where(
Reports.store == store, Reports.product == prod)
dict_store["store"] = store.name if cpt < 1 else ""
dict_store["product"] = prod.name
dict_store["sum_qty_in"] = repts.select(
peewee.fn.SUM(Reports.qty_use)).where(Reports.type_ == Reports.E).scalar()
dict_store["sum_qty_out"] = repts.select(
peewee.fn.SUM(Reports.qty_use)).where(Reports.type_ == Reports.S).scalar()
cpt += 1
reports.append(dict_store)
self.data = [(rep.get('store'), rep.get('product'), rep.get('sum_qty_in'),
rep.get('sum_qty_out')) for rep in reports]
示例3: save_b
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def save_b(self):
''' add operation '''
# entete de la facture
if not self.table_in.isvalid:
return False
date = str(self.date.text())
datetime_ = date_to_datetime(date)
store = self.liste_store[self.box_mag.currentIndex()]
values_t = self.table_in.get_table_items()
for ligne in values_t:
qty, name = ligne
product = Product.select().where(Product.name == name).get()
rep = Reports(orders=None, type_=Reports.E, store=store,
date=datetime_, product=product,
qty_use=int(qty))
try:
rep.save()
except:
self.parent.Notify(
u"Ce mouvement n'a pas pu être enrgistré dans les raports", "error")
return False
self.parent.change_context(GReportViewWidget)
self.parent.Notify(u"L'entrée des articles avec succès", "success")
示例4: set_data_for
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def set_data_for(self, value=None):
products = [(Product.get(id=rpt.product_id).name) for rpt in
Report.select(fn.Distinct(Report.product))]
if value:
products = [(prod.name) for prod in Product.select().where(Product.name.contains(value))
.where(Product.name << products).order_by(Product.name.desc())]
self.data = [(prd, "") for prd in products]
示例5: set_data_for
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def set_data_for(self, prod_find):
products = Product.select().order_by(Product.name.asc())
if prod_find:
products = products.where(Product.name.contains(prod_find))
rest = self.restor_pew_order()
self.data = [(2 if prod.name in rest.keys() else 0,
rest[prod.name] if prod.name in rest.keys() else "",
prod.name) for prod in products]
示例6: shipping
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def shipping():
tags = [product.name for product in Product.select()]
tags += [descriptor.description for descriptor in Descriptor.select()]
tags += [brand.name for brand in Brand.select()]
tags.sort()
return render_template(
"shipper_dashboard.html", Order=Order, Stock=Stock, tags=tags, fn=fn, current_user=current_user
)
示例7: lastes_reports
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def lastes_reports():
list_rep = []
for store in Store.select():
for prod in Product.select():
try:
list_rep.append(Reports.filter(deleted=False, store=store,
product=prod)
.order_by(Reports.date.desc()).get())
except Exception as e:
# print(e)
pass
return list_rep
示例8: buyer
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def buyer():
stocks = Stock.select().where(Stock.bought == False)
stocks = [
{"id": json.dumps(str(stock.id)), "stock": stock} for stock in stocks
] # this will be used for adding listings to the homepage
tags = [product.name for product in Product.select()]
tags += [descriptor.description for descriptor in Descriptor.select()]
tags += [brand.name for brand in Brand.select()]
tags.sort()
return render_template("buyer_dashboard.html", stocks=stocks, Order=Order, Stock=Stock, tags=tags, fn=fn)
示例9: cellHover
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def cellHover(self, row, column):
item = self.item(row, column)
if self.current_hover != [row, column]:
# item.setBackground(QColor('moccasin'))
if column in [3, 4]:
item = self.item(row, column)
name_product = self.data[item.row()][2]
qtte_in_box = Product.select().where(
Product.name == str(name_product)).get().number_parts_box
item.setToolTip("{} pièces".format(
int(self.data[item.row()][item.column()]) * int(qtte_in_box)))
self.current_hover = [row, column]
示例10: popup
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def popup(self, pos):
row = self.selectionModel().selection().indexes()[0].row()
if (len(self.data) - 1) < row:
return False
self.product = Product.select().where(
Product.name == self.data[row][1]).get()
menu = QMenu()
menu.addAction(QIcon(u"{}edit.png".format(Config.img_cmedia)),
u"modifier", lambda: self.prod_edit(self.product))
menu.addAction(QIcon("{}del.png".format(Config.img_cmedia)),
u"supprimer", lambda: self.prod_del(self.product))
self.action = menu.exec_(self.mapToGlobal(pos))
示例11: __init__
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def __init__(self, product, parent=0, *args, **kwargs):
super(By_productViewWidget, self).__init__(parent=parent, *args, **kwargs)
FPeriodHolder.__init__(self, *args, **kwargs)
self.parentWidget().setWindowTitle(Config.NAME_ORGA + u" Par product")
product = Product.select().where(Product.name.contains(product)).get()
self.title = FPageTitle(u"Rapports du product: {name}".format(name=product.name))
self.table = By_productTableWidget(product, parent=self,
main_date=self.main_date)
vbox = QVBoxLayout()
vbox.addWidget(self.title)
vbox.addWidget(self.periods_bar)
vbox.addWidget(self.table)
self.setLayout(vbox)
示例12: set_data_for
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def set_data_for(self, main_date):
reports = []
self.totals = 0
self.total_sum_d1 = 0
self.total_sum_d2 = 0
self.total_sum_d3 = 0
self.total_sum_d4 = 0
self.total_sum_d5 = 0
self.total_sum_d6 = 0
try:
self.date_on, self.date_end = main_date.current.current
except Exception as e:
self.date_on, self.date_end = main_date.current
products = [(Product.get(id=rpt.product_id).name) for rpt in
Report.select(fn.Distinct(Report.product)).where(
Report.date >= self.date_on, Report.date <= self.date_end,
Report.type_ == Report.S)]
products = [(prod.name) for prod in Product.select().where(
Product.name << products).order_by(Product.name.desc())]
for prod_name in products:
on = date_on_or_end(self.date_on)
end = date_on_or_end(self.date_end, on=False)
dict_store = {}
repts = Report.select().where(Report.type_ == Report.S,
Report.product == Product.get(
name=prod_name))
dict_store["product"] = prod_name
dict_store["sum_week"] = repts.select(
peewee.fn.SUM(Report.qty)).where(Report.date >= on,
Report.date <= end).scalar() or 0
self.totals += (dict_store["sum_week"])
end = on + timedelta(days=1, seconds=-1)
dict_store["sum_d1"] = repts.select(
peewee.fn.SUM(Report.qty)).where(Report.date >= on,
Report.date <= end).scalar() or 0
self.total_sum_d1 += dict_store["sum_d1"]
on += timedelta(1)
end = on + timedelta(days=1, seconds=-1)
dict_store["sum_d2"] = repts.select(
peewee.fn.SUM(Report.qty)).where(Report.date >= on,
Report.date <= end).scalar() or 0
self.total_sum_d2 += dict_store["sum_d2"]
on += timedelta(1)
end = on + timedelta(days=1, seconds=-1)
dict_store["sum_d3"] = repts.select(
peewee.fn.SUM(Report.qty)).where(Report.date >= on,
Report.date <= end).scalar() or 0
self.total_sum_d3 += dict_store["sum_d3"]
on += timedelta(1)
end = on + timedelta(days=1, seconds=-1)
dict_store["sum_d4"] = repts.select(
peewee.fn.SUM(Report.qty)).where(Report.date >= on,
Report.date <= end).scalar() or 0
self.total_sum_d4 += dict_store["sum_d4"]
on += timedelta(1)
end = on + timedelta(days=1, seconds=-1)
dict_store["sum_d5"] = repts.select(
peewee.fn.SUM(Report.qty)).where(Report.date >= on,
Report.date <= end).scalar() or 0
self.total_sum_d5 += dict_store["sum_d5"]
on += timedelta(1)
end = on + timedelta(days=1, seconds=-1)
dict_store["sum_d6"] = repts.select(
peewee.fn.SUM(Report.qty)).where(Report.date >= on,
Report.date <= end).scalar() or 0
self.total_sum_d6 += dict_store["sum_d6"]
reports.append(dict_store)
self.data = [(rep.get('product'), rep.get('sum_d1'),
rep.get('sum_d2'), rep.get('sum_d3'), rep.get('sum_d4'),
rep.get('sum_d5'), rep.get('sum_d6'),
rep.get('sum_week'), "") for rep in reports]
示例13: set_data_for
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import select [as 别名]
def set_data_for(self):
self.data = [(prod.category.name, prod.name)
for prod in Product.select().order_by(Product.name.asc())]