def add_product(self, name, category, percentage):
""" Add product to consumption list. If the products has no null price
only.
:param str name: Product name
:param str category: Category Name
"""
# Find category widget
cat_widget = None
for cat in self.categories:
if category == cat.text(0):
cat_widget = cat
if not cat_widget:
return
category = api.categories.get_unique(name=category)
product = api.products.get_unique(
category=category['id'],
name=name
)
if not product:
return
for price in api.prices.get(product=product['id']):
if float(price['value']) != 0:
break
else:
return
prod_widget = QtWidgets.QTreeWidgetItem([name])
cat_widget.addChild(prod_widget)
self.products.append(prod_widget)
评论列表
文章目录