本文整理汇总了Python中stoqlib.domain.workorder.WorkOrderItem.reserve方法的典型用法代码示例。如果您正苦于以下问题:Python WorkOrderItem.reserve方法的具体用法?Python WorkOrderItem.reserve怎么用?Python WorkOrderItem.reserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.workorder.WorkOrderItem
的用法示例。
在下文中一共展示了WorkOrderItem.reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_remove
# 需要导入模块: from stoqlib.domain.workorder import WorkOrderItem [as 别名]
# 或者: from stoqlib.domain.workorder.WorkOrderItem import reserve [as 别名]
def test_remove(self):
workorder = self.create_workorder()
product1 = self.create_product(stock=10, branch=workorder.branch)
product2 = self.create_product(stock=10, branch=workorder.branch)
item1 = WorkOrderItem(self.store, sellable=product1.sellable,
quantity=5)
item2 = WorkOrderItem(self.store, sellable=product1.sellable,
quantity=5)
for item in [item1, item2]:
self.assertRaises(AssertionError, workorder.remove_item, item)
workorder.add_item(item1)
workorder.add_item(item2)
# Only item1 will reserve stock. The other one is to test it being
# removed without ever decreasing the stock
item1.reserve(item1.quantity)
self.assertEqual(
product1.storable.get_balance_for_branch(workorder.branch), 5)
self.assertEqual(
product2.storable.get_balance_for_branch(workorder.branch), 10)
for item in [item1, item2]:
workorder.remove_item(item)
storable = item.sellable.product.storable
# Everything should be back to the stock, like
# the item never existed
self.assertEqual(
storable.get_balance_for_branch(workorder.branch), 10)
with self.sysparam(SYNCHRONIZED_MODE=True):
item = self.create_work_order_item()
order = item.order
before_remove = self.store.find(WorkOrderItem).count()
order.remove_item(item)
after_remove = self.store.find(WorkOrderItem).count()
# The item should still be on the database
self.assertEqual(before_remove, after_remove)
# But not related to the loan
self.assertEquals(self.store.find(WorkOrderItem, order=order).count(), 0)