本文整理汇总了Python中stoqlib.domain.product.Storable.decrease_stock方法的典型用法代码示例。如果您正苦于以下问题:Python Storable.decrease_stock方法的具体用法?Python Storable.decrease_stock怎么用?Python Storable.decrease_stock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.product.Storable
的用法示例。
在下文中一共展示了Storable.decrease_stock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_balance
# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import decrease_stock [as 别名]
def test_get_balance(self):
p = self.create_product()
b1 = self.create_branch()
b2 = self.create_branch()
b3 = self.create_branch()
storable = Storable(store=self.store, product=p)
self.assertEqual(storable.get_balance_for_branch(b1), 0)
self.assertEqual(storable.get_balance_for_branch(b2), 0)
self.assertEqual(storable.get_balance_for_branch(b3), 0)
self.assertEqual(storable.get_total_balance(), 0)
# Only b1 and b2 will increase stock
storable.increase_stock(5, b1, 0, None)
storable.increase_stock(10, b2, 0, None)
self.assertEqual(storable.get_balance_for_branch(b1), 5)
self.assertEqual(storable.get_balance_for_branch(b2), 10)
self.assertEqual(storable.get_balance_for_branch(b3), 0)
self.assertEqual(storable.get_total_balance(), 15)
# b1 will decrease *all* it's stock
storable.decrease_stock(5, b1, 0, None)
self.assertEqual(storable.get_balance_for_branch(b1), 0)
self.assertEqual(storable.get_balance_for_branch(b2), 10)
self.assertEqual(storable.get_balance_for_branch(b3), 0)
self.assertEqual(storable.get_total_balance(), 10)
示例2: testIncreaseDecreaseStock
# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import decrease_stock [as 别名]
def testIncreaseDecreaseStock(self):
branch = get_current_branch(self.store)
product = self.create_product()
storable = Storable(product=product, store=self.store)
stock_item = storable.get_stock_item(branch)
self.failIf(stock_item is not None)
storable.increase_stock(1, branch, 0, 0)
stock_item = storable.get_stock_item(branch)
self.assertEquals(stock_item.stock_cost, 0)
storable.increase_stock(1, branch, 0, 0, unit_cost=10)
stock_item = storable.get_stock_item(branch)
self.assertEquals(stock_item.stock_cost, 5)
stock_item = storable.decrease_stock(1, branch, 0, 0)
self.assertEquals(stock_item.stock_cost, 5)
storable.increase_stock(1, branch, 0, 0)
stock_item = storable.get_stock_item(branch)
self.assertEquals(stock_item.stock_cost, 5)
storable.increase_stock(2, branch, 0, 0, unit_cost=15)
stock_item = storable.get_stock_item(branch)
self.assertEquals(stock_item.stock_cost, 10)