本文整理汇总了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)
示例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)
示例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)
示例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)
示例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")
示例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")
示例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())