本文整理汇总了Python中models.Product.filter方法的典型用法代码示例。如果您正苦于以下问题:Python Product.filter方法的具体用法?Python Product.filter怎么用?Python Product.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Product
的用法示例。
在下文中一共展示了Product.filter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: click_item
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import filter [as 别名]
def click_item(self, row, column, *args):
if column != 2:
self.choix = Product.filter(name=self.data[row][1]).get()
self.parent.table_info.refresh_(self.choix.id)
if column == 2:
# self.removeRow(row)
self.choix = Product.filter(name=self.data[row][1]).get()
self.parent.table_invoice.refresh_(self.choix)
示例2: filter
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import filter [as 别名]
def filter(request):
context = get_default_context(request)
catalog = request.POST['catalog']
price_max = request.POST['price_max']
price_min = request.POST['price_min']
size = json.loads(request.POST['size'])
context['product'] = Product.filter(str(catalog), int(price_min), int(price_max), size).values()
return render_to_response('catalog/product.html', context)
示例3: changed_value
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import filter [as 别名]
def changed_value(self, refresh=False):
""" Calcule les Resultat """
mtt_ht = 0
for row_num in xrange(0, self.data.__len__()):
last_report = Product.filter(name=str(self.item(row_num, 1)
.text())).get().last_report
try:
qtremaining = last_report.remaining
except AttributeError:
qtremaining = 0
qtsaisi = is_int(self.cellWidget(row_num, 0).text())
pu = is_int(self.cellWidget(row_num, 2).text())
self.isvalid = True
viderreur_qtsaisi = ""
viderreur_pu = ""
stylerreur = "background-color: rgb(255, 235, 235);" + \
"border: 3px double SeaGreen"
if qtsaisi == 0:
viderreur_qtsaisi = stylerreur
self.cellWidget(row_num, 0).setToolTip(u"obligatoire")
self.isvalid = False
if pu == 0:
viderreur_pu = stylerreur
self.cellWidget(row_num, 0).setToolTip(u"obligatoire")
self.isvalid = False
self.cellWidget(row_num, 0).setStyleSheet(viderreur_qtsaisi)
self.cellWidget(row_num, 2).setStyleSheet(viderreur_pu)
self.cellWidget(row_num, 0).setToolTip("")
if qtremaining < qtsaisi:
self.cellWidget(row_num, 0).setStyleSheet("font-size:20px;"
" color: red")
self.cellWidget(row_num,
0).setToolTip(u"%s est > %s (stock"
u" remaining)" % (qtsaisi, qtremaining))
# self.isvalid = False
# return False
ui_item = (qtsaisi * pu)
mtt_ht += ui_item
montt = QTableWidgetItem(formatted_number(ui_item))
montt.setTextAlignment(Qt.AlignRight)
self.setItem(row_num, 3, montt)
monttc = QTableWidgetItem(formatted_number(mtt_ht))
monttc.setTextAlignment(Qt.AlignRight)
self.setItem(row_num + 1, 3, monttc)
示例4: click_item
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import filter [as 别名]
def click_item(self, row, column, *args):
self.choix = Product.filter(name=self.data[row][0]).get()
self.parent.table_info.refresh_(self.choix.id)
if column == 1:
self.parent.table_buy.refresh_(self.choix)
示例5: save_b
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import filter [as 别名]
def save_b(self):
''' add operation '''
# entete de la facture
if not self.table_invoice.isvalid:
return False
try:
num_invoice = int(self.num_invoice.text())
self.num_invoice_error.setText(u"")
except:
self.pixmap = QPixmap(u"{img_media}{img}".format(img_media=Config.img_media,
img="warning.png"))
self.num_invoice.setStyleSheet("background-color: rgb(255, 235, 235);")
self.num_invoice_error.setToolTip(u"Le numero de facture est obligatoire.")
self.num_invoice_error.setPixmap(self.pixmap)
invoice_date = str(self.invoice_date.text())
name_client = str(self.name_client.text())
datetime_ = date_to_datetime(invoice_date)
values_t = self.table_invoice.get_table_items()
if name_client == "":
self.name_client.setStyleSheet("background-color: rgb(255, 235, 235);")
self.pixmap = QPixmap(u"{img_media}{img}".format(img_media=Config.img_media,
img="decline.png"))
self.name_client_error.setToolTip(u"Nom du client est obligatoire.")
self.name_client_error.setPixmap(self.pixmap)
return False
# if num_invoice > Config.credit:
# raise_error(("Avertisement"), u"<h2>Veuillez payer la reste de la licence</h2>")
# return False
invoice = Invoice()
try:
invoice.owner = Owner.get(islog=True)
except:
if Config.DEBUG:
invoice.owner = Owner.get(username='root')
else:
return False
invoice.number = num_invoice
invoice.date_ord = datetime_
invoice.client = name_client.capitalize()
invoice.location = "Bamako"
invoice.type_ = "Facture"
invoice.subject = ""
invoice.tax = False
invoice.otax_rate = 18
try:
invoice.save()
except:
raise_error("Erreur", u"Impossible d'enregistrer l'entête de la facture")
return False
# Save orderitems
try:
order = Invoice.get(number=num_invoice)
except:
return False
for i in values_t:
qty, name, price = i
description = Product.filter(name=name).get()
item = InvoiceItem()
item.invoices = invoice.id
item.quantity = int(i[0])
item.description = description
item.price = int(i[2])
try:
item.save()
self.name_client.clear()
self.num_invoice.clear()
except Exception as e:
print(e)
invoice.delete_instance()
raise_error("Erreur", u"Ce mouvement n'a pas pu etre "
u"enregistré dans les rapports")
return False
self.change_main_context(ShowInvoiceViewWidget,
invoice=invoice)