group_actions_window.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Enibar 作者: ENIB 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号