本文整理匯總了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]))