当前位置: 首页>>代码示例>>Python>>正文


Python ProductFullStockView.find_by_branch方法代码示例

本文整理汇总了Python中stoqlib.domain.views.ProductFullStockView.find_by_branch方法的典型用法代码示例。如果您正苦于以下问题:Python ProductFullStockView.find_by_branch方法的具体用法?Python ProductFullStockView.find_by_branch怎么用?Python ProductFullStockView.find_by_branch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stoqlib.domain.views.ProductFullStockView的用法示例。


在下文中一共展示了ProductFullStockView.find_by_branch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testPrice

# 需要导入模块: from stoqlib.domain.views import ProductFullStockView [as 别名]
# 或者: from stoqlib.domain.views.ProductFullStockView import find_by_branch [as 别名]
    def testPrice(self):
        p1 = self.create_product()
        results = ProductFullStockView.find_by_branch(self.store, None).find(
            ProductFullStockView.product_id == p1.id)
        self.failUnless(list(results))
        pv = results[0]
        self.assertEquals(pv.price, 10)

        # Set a sale price
        sellable = p1.sellable
        sellable.on_sale_price = Decimal('5.55')

        # And a interval that includes today
        yesterday = localtoday().date() - datetime.timedelta(days=1)
        tomorrow = localtoday().date() + datetime.timedelta(days=1)
        sellable.on_sale_start_date = yesterday
        sellable.on_sale_end_date = tomorrow

        results = ProductFullStockView.find_by_branch(self.store, None).find(
            ProductFullStockView.product_id == p1.id)
        self.assertEquals(results[0].price, Decimal('5.55'))

        # Testing with a sale price set, but in the past
        date1 = localtoday().date() - datetime.timedelta(days=10)
        date2 = localtoday().date() - datetime.timedelta(days=5)
        sellable.on_sale_start_date = date1
        sellable.on_sale_end_date = date2

        results = ProductFullStockView.find_by_branch(self.store, None).find(
            ProductFullStockView.product_id == p1.id)
        self.assertEquals(results[0].price, 10)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:33,代码来源:test_views.py

示例2: testSelectByBranch

# 需要导入模块: from stoqlib.domain.views import ProductFullStockView [as 别名]
# 或者: from stoqlib.domain.views.ProductFullStockView import find_by_branch [as 别名]
    def testSelectByBranch(self):
        branch = self.create_branch()
        p1 = self.create_product(branch=branch, stock=1)

        results = ProductFullStockView.find_by_branch(self.store, branch)
        self.failUnless(list(results))
        # FIXME: Storm does not support count() with group_by
        # self.assertEquals(results.count(), 1)
        self.assertEquals(len(list(results)), 1)

        results = ProductFullStockView.find_by_branch(self.store, branch)
        results = results.find(ProductFullStockView.product_id == p1.id)
        self.failUnless(list(results))
        self.assertEquals(len(list(results)), 1)
开发者ID:marianaanselmo,项目名称:stoq,代码行数:16,代码来源:test_views.py

示例3: test_select_by_branch

# 需要导入模块: from stoqlib.domain.views import ProductFullStockView [as 别名]
# 或者: from stoqlib.domain.views.ProductFullStockView import find_by_branch [as 别名]
    def test_select_by_branch(self):
        branch = self.create_branch()
        p1 = self.create_product(branch=branch, stock=1)

        results = ProductFullStockView.find_by_branch(self.store, branch)
        self.failUnless(list(results))
        # FIXME: Storm does not support count() with group_by
        # self.assertEquals(results.count(), 1)
        # The results should have 11 items. 10 for the products that already
        # exists, and 1 more for the one we created
        self.assertEquals(len(list(results)), 11)

        results = ProductFullStockView.find_by_branch(self.store, branch)
        results = results.find(ProductFullStockView.product_id == p1.id)
        self.failUnless(list(results))
        self.assertEquals(len(list(results)), 1)
开发者ID:dionimf,项目名称:stoq,代码行数:18,代码来源:test_views.py

示例4: test_stock_cost

# 需要导入模块: from stoqlib.domain.views import ProductFullStockView [as 别名]
# 或者: from stoqlib.domain.views.ProductFullStockView import find_by_branch [as 别名]
    def test_stock_cost(self):
        branch = self.create_branch()
        p1 = self.create_product(branch=branch, stock=1)

        p2 = self.create_product()

        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
        self.failUnless(list(results))
        pv = results[0]
        self.assertEquals(pv.stock_cost, 10)

        branch = get_current_branch(self.store)
        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p2.id)
        self.failUnless(list(results))
        pv = results[0]
        self.assertEquals(pv.stock_cost, 0)
开发者ID:rg3915,项目名称:stoq,代码行数:18,代码来源:test_views.py

示例5: test_unit_description

# 需要导入模块: from stoqlib.domain.views import ProductFullStockView [as 别名]
# 或者: from stoqlib.domain.views.ProductFullStockView import find_by_branch [as 别名]
    def test_unit_description(self):
        p1 = self.create_product()
        p1.sellable.unit = self.create_sellable_unit()
        p1.sellable.unit.description = u"kg"

        p2 = self.create_product()

        results = ProductFullStockView.find_by_branch(self.store, None)
        results = results.find(ProductFullStockView.product_id == p1.id)
        self.failUnless(list(results))
        product_view = results[0]
        self.assertEquals(product_view.get_unit_description(), u"kg")

        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p2.id)
        self.failUnless(list(results))
        product_view = results[0]
        self.assertEquals(product_view.get_unit_description(), u"un")
开发者ID:rg3915,项目名称:stoq,代码行数:19,代码来源:test_views.py

示例6: test_get_product_and_category_description

# 需要导入模块: from stoqlib.domain.views import ProductFullStockView [as 别名]
# 或者: from stoqlib.domain.views.ProductFullStockView import find_by_branch [as 别名]
    def test_get_product_and_category_description(self):
        p1 = self.create_product()
        p1.sellable.category = self.create_sellable_category()
        p1.sellable.category.description = u"category"

        p2 = self.create_product()

        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p1.id)
        self.failUnless(list(results))
        pv = results[0]
        desc = pv.get_product_and_category_description()
        self.assertEquals(desc, u"[category] Description")

        results = ProductFullStockView.find_by_branch(self.store, None).find(ProductFullStockView.product_id == p2.id)
        self.failUnless(list(results))
        pv = results[0]
        desc = pv.get_product_and_category_description()
        self.assertEquals(desc, u"Description")
开发者ID:rg3915,项目名称:stoq,代码行数:20,代码来源:test_views.py

示例7: test_highjacked_equality

# 需要导入模块: from stoqlib.domain.views import ProductFullStockView [as 别名]
# 或者: from stoqlib.domain.views.ProductFullStockView import find_by_branch [as 别名]
    def test_highjacked_equality(self):
        self.clean_domain([StockTransactionHistory, ProductStockItem, Storable, ProductSupplierInfo, Product])

        branch = self.create_branch()
        self.create_product(branch=branch, stock=1)

        res = self.store.find(ProductFullStockView)
        res_by_branch = ProductFullStockView.find_by_branch(self.store, branch)

        self.assertEqual(res[0], res_by_branch[0])
        self.assertEqual(res_by_branch[0], res[0])

        product = self.create_product()
        other_viewable = self.store.find(ProductFullStockView, Sellable.id == product.sellable.id).one()
        self.assertNotEqual(res[0], other_viewable)
        self.assertNotEqual(res[0], object())
开发者ID:amaurihamasu,项目名称:stoq,代码行数:18,代码来源:test_views.py


注:本文中的stoqlib.domain.views.ProductFullStockView.find_by_branch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。