本文整理汇总了Python中stoqlib.domain.inventory.Inventory.create_inventory方法的典型用法代码示例。如果您正苦于以下问题:Python Inventory.create_inventory方法的具体用法?Python Inventory.create_inventory怎么用?Python Inventory.create_inventory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stoqlib.domain.inventory.Inventory
的用法示例。
在下文中一共展示了Inventory.create_inventory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _register_inventory
# 需要导入模块: from stoqlib.domain.inventory import Inventory [as 别名]
# 或者: from stoqlib.domain.inventory.Inventory import create_inventory [as 别名]
def _register_inventory(self):
query = Storable.id == self._product.id
inventory = Inventory.create_inventory(
self.store, branch=self._branch, responsible=api.get_current_user(self.store), query=query
)
# At this point, the inventory should have only one item.
item = inventory.get_items().one()
item.counted_quantity = item.actual_quantity = self.model.quantity
# item.product_cost = self.model.cost
item.reason = self.model.reason
item.adjust(invoice_number=None)
inventory.close()
示例2: on_confirm
# 需要导入模块: from stoqlib.domain.inventory import Inventory [as 别名]
# 或者: from stoqlib.domain.inventory.Inventory import create_inventory [as 别名]
def on_confirm(self):
# We are using this hook as a callback for the finish button
branch = self.store.fetch(self.model.branch)
responsible = self.store.fetch(self.model.user)
query = self._get_sellables_query()
return Inventory.create_inventory(self.store, branch, responsible, query)
示例3: test_create_inventory
# 需要导入模块: from stoqlib.domain.inventory import Inventory [as 别名]
# 或者: from stoqlib.domain.inventory.Inventory import create_inventory [as 别名]
def test_create_inventory(self):
branch = self.create_branch()
# A category so that we can filter the products we want in the
# inventory
cat = self.create_sellable_category()
# First, lets create some sellables for our test
# One storable with stock (it should be in the inventory)
storable1 = self.create_storable(branch=branch, stock=10)
storable1.product.sellable.category = cat
# One storable without stock (it should NOT be in the inventory)
storable2 = self.create_storable()
storable2.product.sellable.category = cat
# One storable with one batch, and stock (it should be in the inventory)
storable3 = self.create_storable()
storable3.is_batch = True
storable3.product.sellable.category = cat
batch1 = self.create_storable_batch(storable3, u'123')
storable3.increase_stock(3, branch, batch=batch1,
type=0, object_id=None, unit_cost=10)
# One storable with one batch and a stock item (but without stock).
# it should be on the inventory
storable4 = self.create_storable()
storable4.is_batch = True
storable4.product.sellable.category = cat
batch2 = self.create_storable_batch(storable4, u'124')
storable4.increase_stock(1, branch, batch=batch2,
type=0, object_id=None, unit_cost=10)
storable4.decrease_stock(1, branch, batch=batch2,
type=0, object_id=None)
# Then, lets open the inventory
responsible = self.create_user()
query = Sellable.category == cat
inventory = Inventory.create_inventory(self.store, branch, responsible, query)
self.assertEquals(inventory.branch, branch)
self.assertEquals(inventory.responsible, responsible)
# There should be only 3 items in the inventory
items = inventory.get_items()
self.assertEqual(items.count(), 3)
self.assertEqual(set(i.product for i in items),
set([storable1.product,
storable3.product,
storable4.product]))
# Use this examples to also test get_inventory_data
data = list(inventory.get_inventory_data())
self.assertEquals(len(data), 3)
# each row should have 5 items
row = data[0]
self.assertEquals(len(row), 5)
self.assertEquals(set(i[0] for i in data), set(items))
self.assertEquals(set(i[1] for i in data),
set([storable1, storable3, storable4]))
self.assertEquals(set(i[4] for i in data),
set([None, batch1, batch2]))