當前位置: 首頁>>代碼示例>>Python>>正文


Python Inventory.create_inventory方法代碼示例

本文整理匯總了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()
開發者ID:stoq,項目名稱:stoq,代碼行數:14,代碼來源:producteditor.py

示例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)
開發者ID:EasyDevSolutions,項目名稱:stoq,代碼行數:8,代碼來源:inventoryeditor.py

示例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]))
開發者ID:dionimf,項目名稱:stoq,代碼行數:65,代碼來源:test_inventory.py


注:本文中的stoqlib.domain.inventory.Inventory.create_inventory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。