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


Python Storable.decrease_stock方法代码示例

本文整理汇总了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)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:28,代码来源:test_product.py

示例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)
开发者ID:romaia,项目名称:stoq,代码行数:27,代码来源:test_product.py


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