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


Python Storable.increase_stock方法代码示例

本文整理汇总了Python中stoqlib.domain.product.Storable.increase_stock方法的典型用法代码示例。如果您正苦于以下问题:Python Storable.increase_stock方法的具体用法?Python Storable.increase_stock怎么用?Python Storable.increase_stock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stoqlib.domain.product.Storable的用法示例。


在下文中一共展示了Storable.increase_stock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_balance

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_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: test_can_remove

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
    def test_can_remove(self):
        branch = get_current_branch(self.store)
        sellable = self.create_sellable()
        storable = Storable(product=sellable.product, store=self.store)
        self.failUnless(sellable.can_remove())

        storable.increase_stock(1, branch, 0, None)
        sale = self.create_sale()
        sale.status = Sale.STATUS_QUOTE
        sale.branch = branch
        sale.add_sellable(sellable)
        self.failIf(sellable.can_remove())

        # Can't remove the sellable if it's in a purchase.
        from stoqlib.domain.purchase import PurchaseItem
        sellable = self.create_sellable()
        Storable(product=sellable.product, store=self.store)
        self.assertTrue(sellable.can_remove())
        PurchaseItem(store=self.store,
                     quantity=8, quantity_received=0,
                     cost=125, base_cost=125,
                     sellable=sellable,
                     order=self.create_purchase_order())
        self.assertFalse(sellable.can_remove())

        # The delivery service cannot be removed.
        sellable = sysparam(self.store).DELIVERY_SERVICE.sellable
        self.failIf(sellable.can_remove())
开发者ID:LeonamSilva,项目名称:stoq,代码行数:30,代码来源:test_sellable.py

示例3: add_product

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
 def add_product(self, sale, price=None, quantity=1):
     from stoqlib.domain.product import Storable
     product = self.create_product(price=price)
     sellable = product.sellable
     sellable.tax_constant = self.create_sellable_tax_constant()
     sale.add_sellable(sellable, quantity=quantity)
     storable = Storable(product=product, store=self.store)
     storable.increase_stock(100, get_current_branch(self.store), 0, 0)
     return sellable
开发者ID:romaia,项目名称:stoq,代码行数:11,代码来源:exampledata.py

示例4: create_loan_item

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
    def create_loan_item(self, loan=None, quantity=1):
        from stoqlib.domain.loan import LoanItem
        from stoqlib.domain.product import Storable, StockTransactionHistory

        loan = loan or self.create_loan()
        sellable = self.create_sellable()
        storable = Storable(product=sellable.product, store=self.store)
        storable.increase_stock(10, loan.branch, type=StockTransactionHistory.TYPE_INITIAL, object_id=None)
        return LoanItem(loan=loan, sellable=sellable, price=10, quantity=quantity, store=self.store)
开发者ID:rg3915,项目名称:stoq,代码行数:11,代码来源:exampledata.py

示例5: create_storable

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
    def create_storable(self, product=None, branch=None, stock=0, unit_cost=None, is_batch=False):
        from stoqlib.domain.product import Storable, StockTransactionHistory

        if not product:
            sellable = self.create_sellable()
            product = sellable.product
        storable = Storable(product=product, store=self.store, is_batch=is_batch)
        if branch and stock:
            storable.increase_stock(
                stock, branch, type=StockTransactionHistory.TYPE_INITIAL, object_id=None, unit_cost=unit_cost
            )
        return storable
开发者ID:rg3915,项目名称:stoq,代码行数:14,代码来源:exampledata.py

示例6: _create_sale

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
    def _create_sale(self, invoice_number, due_date=None):
        sale = self.create_sale()
        sale.invoice_number = invoice_number
        sale.branch = get_current_branch(self.store)
        tax_types = cycle(['aliq', 'nt', 'outr'])
        # [0] - Description
        # [1] - Code
        # [2] - Price
        # [3] - Quantity
        # [4] - Base price
        for tax_type, data in zip(tax_types, [
                (u"Laranja", u"1", Decimal(1), Decimal(10), Decimal('1.5')),
                (u"Limão", u"2", Decimal('0.5'), Decimal(15), Decimal('0.3')),
                (u"Abacaxi", u"3", Decimal(3), Decimal(1), Decimal('3.3')),
                (u"Cenoura", u"4", Decimal('1.5'), Decimal(6), Decimal('1.9')),
                (u"Pêssego", u"5", Decimal('3.5'), Decimal(3), Decimal('3.0'))]):
            sellable = self._create_sellable(data[0], data[1], data[2])
            storable = Storable(product=sellable.product,
                                store=self.store)
            storable.increase_stock(data[3], get_current_branch(self.store),
                                    StockTransactionHistory.TYPE_INITIAL,
                                    sale.id)

            sale_item = sale.add_sellable(sellable, data[3])
            if tax_type == 'aliq':
                self._add_aliq(sale_item)
            elif tax_type == 'nt':
                self._add_nt(sale_item)
            elif tax_type == 'outr':
                self._add_outr(sale_item)

            # Set the base price to test the discount in NF-e.
            sale_item.base_price = data[4]
            icms_info = sale_item.icms_info
            icms_info.csosn = 201
            icms_info.p_icms_st = 1

            self._update_taxes(sale_item)

        sale.client = self.create_client()
        self._create_address(sale.client.person,
                             street=u"Rua dos Tomates",
                             streetnumber=2666,
                             postal_code=u'87654-321')
        sale.order()

        method = PaymentMethod.get_by_name(self.store, u'money')
        method.create_payment(Payment.TYPE_IN, sale.group, sale.branch,
                              sale.get_sale_subtotal(),
                              due_date=due_date)
        sale.confirm()

        return sale
开发者ID:adrianoaguiar,项目名称:stoq,代码行数:55,代码来源:test_nfe.py

示例7: create_storable

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
 def create_storable(self, product=None, branch=None, stock=0,
                     unit_cost=None):
     from stoqlib.domain.product import Storable
     if not product:
         sellable = self.create_sellable()
         product = sellable.product
     storable = Storable(product=product, store=self.store)
     if branch and stock:
         if unit_cost:
             storable.increase_stock(stock, branch, 0, 0, unit_cost)
         else:
             storable.increase_stock(stock, branch, 0, 0)
     return storable
开发者ID:romaia,项目名称:stoq,代码行数:15,代码来源:exampledata.py

示例8: testIncreaseDecreaseStock

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_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

示例9: create_loan_item

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
 def create_loan_item(self, loan=None, product=None, quantity=1):
     from stoqlib.domain.loan import LoanItem
     from stoqlib.domain.product import Storable
     loan = loan or self.create_loan()
     if not product:
         sellable = self.create_sellable()
         storable = Storable(product=sellable.product,
                             store=self.store)
         storable.increase_stock(10, loan.branch, 0, 0)
     else:
         sellable = product.sellable
         storable = product.storable
     return LoanItem(loan=loan, sellable=sellable, price=10,
                     quantity=quantity, store=self.store)
开发者ID:romaia,项目名称:stoq,代码行数:16,代码来源:exampledata.py

示例10: create_inventory_item

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
 def create_inventory_item(self, inventory=None, quantity=5):
     from stoqlib.domain.inventory import InventoryItem
     from stoqlib.domain.product import Storable
     if not inventory:
         inventory = self.create_inventory()
     sellable = self.create_sellable()
     product = sellable.product
     storable = Storable(product=product, store=self.store)
     storable.increase_stock(quantity, inventory.branch, 0, 0)
     return InventoryItem(product=product,
                          product_cost=product.sellable.cost,
                          recorded_quantity=quantity,
                          inventory=inventory,
                          store=self.store)
开发者ID:romaia,项目名称:stoq,代码行数:16,代码来源:exampledata.py

示例11: create_transfer_order_item

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
 def create_transfer_order_item(self, order=None, quantity=5, sellable=None):
     from stoqlib.domain.product import Product, Storable
     from stoqlib.domain.transfer import TransferOrderItem
     if not order:
         order = self.create_transfer_order()
     if not sellable:
         sellable = self.create_sellable()
     product = self.store.find(Product, sellable=sellable).one()
     if not product.storable:
         storable = Storable(product=product, store=self.store)
         storable.increase_stock(quantity, order.source_branch, 0, 0)
     return TransferOrderItem(sellable=sellable,
                              transfer_order=order,
                              quantity=quantity,
                              store=self.store)
开发者ID:tmaxter,项目名称:stoq,代码行数:17,代码来源:exampledata.py

示例12: create_product

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
    def create_product(self, price=None, create_supplier=True,
                       branch=None, stock=None):
        from stoqlib.domain.product import Storable
        sellable = self.create_sellable(price=price)
        if create_supplier:
            self.create_product_supplier_info(product=sellable.product)
        product = sellable.product
        if not branch:
            branch = get_current_branch(self.store)

        if stock:
            storable = Storable(product=product, store=self.store)
            storable.increase_stock(stock, branch, 0, 0, unit_cost=10)

        return product
开发者ID:romaia,项目名称:stoq,代码行数:17,代码来源:exampledata.py

示例13: create_inventory_item

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
 def create_inventory_item(self, inventory=None, quantity=5):
     from stoqlib.domain.inventory import InventoryItem
     from stoqlib.domain.product import Storable, StockTransactionHistory
     if not inventory:
         inventory = self.create_inventory()
     sellable = self.create_sellable()
     product = sellable.product
     storable = Storable(product=product, store=self.store)
     storable.increase_stock(quantity, inventory.branch,
                             type=StockTransactionHistory.TYPE_INITIAL,
                             object_id=None)
     return InventoryItem(product=product,
                          product_cost=product.sellable.cost,
                          recorded_quantity=quantity,
                          inventory=inventory,
                          store=self.store)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:18,代码来源:exampledata.py

示例14: testCanRemove

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
    def testCanRemove(self):
        product = self.create_product()
        storable = Storable(product=product, store=self.store)
        self.assertTrue(product.can_remove())

        storable.increase_stock(1, get_current_branch(self.store), 0, 0)
        self.assertFalse(product.can_remove())

        # Product was sold.
        sale = self.create_sale()
        sale.add_sellable(product.sellable, quantity=1, price=10)

        method = PaymentMethod.get_by_name(self.store, u'money')
        method.create_inpayment(sale.group, sale.branch, sale.get_sale_subtotal())

        sale.order()
        sale.confirm()

        self.assertFalse(product.can_remove())

        # Product is a component.
        from stoqlib.domain.product import ProductComponent
        product = self.create_product(10)
        component = self.create_product(5)
        Storable(product=component, store=self.store)
        self.assertTrue(component.can_remove())

        ProductComponent(product=product,
                         component=component,
                         store=self.store)

        self.assertFalse(component.can_remove())

        # Product is used in a production.
        from stoqlib.domain.production import ProductionItem
        product = self.create_product()
        Storable(product=product, store=self.store)
        self.assertTrue(product.can_remove())
        order = self.create_production_order()
        ProductionItem(product=product,
                       order=order,
                       quantity=1,
                       store=self.store)

        self.assertFalse(product.can_remove())
开发者ID:romaia,项目名称:stoq,代码行数:47,代码来源:test_product.py

示例15: create_product

# 需要导入模块: from stoqlib.domain.product import Storable [as 别名]
# 或者: from stoqlib.domain.product.Storable import increase_stock [as 别名]
    def create_product(self, price=None, with_supplier=True, branch=None, stock=None, storable=False, code=u""):
        from stoqlib.domain.product import Storable, StockTransactionHistory

        sellable = self.create_sellable(price=price, code=code)
        if with_supplier:
            self.create_product_supplier_info(product=sellable.product)
        product = sellable.product
        if not branch:
            branch = get_current_branch(self.store)

        if storable or stock:
            storable = Storable(product=product, store=self.store)
        if stock:
            storable.increase_stock(
                stock, branch, type=StockTransactionHistory.TYPE_INITIAL, object_id=None, unit_cost=10
            )

        return product
开发者ID:rg3915,项目名称:stoq,代码行数:20,代码来源:exampledata.py


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