• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python product.Storable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_add_purchase_item

    def test_add_purchase_item(self):
        receiving_order = self.create_receiving_order()
        item = self.create_purchase_order_item()

        with self.assertRaisesRegexp(ValueError, "The purchase item must be on "
                                     "the same purchase of this receiving"):
            receiving_order.add_purchase_item(item)

        receiving_order = self.create_receiving_order()
        item = self.create_purchase_order_item(receiving_order.purchase)

        with self.assertRaisesRegexp(ValueError, "The quantity must be higher "
                                                 "than 0 and lower than the "
                                                 "purchase item's quantity"):
            receiving_order.add_purchase_item(item, quantity=0)

        receiving_order = self.create_receiving_order()
        item = self.create_purchase_order_item(receiving_order.purchase)
        item.quantity_received = 2
        with self.assertRaisesRegexp(ValueError, "The quantity must be lower "
                                                 "than the item's pending "
                                                 "quantity"):
            receiving_order.add_purchase_item(item, quantity=8)

        storable = Storable(store=self.store, product=item.sellable.product)
        storable.is_batch = True
        p = receiving_order.add_purchase_item(item, batch_number=u'12')
        self.assertEqual(p.batch.batch_number, u'12')
开发者ID:pkaislan,项目名称:stoq,代码行数:28,代码来源:test_receiving.py


示例2: test_can_remove

    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,代码行数:28,代码来源:test_sellable.py


示例3: add_product

 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,代码行数:9,代码来源:exampledata.py


示例4: create_loan_item

    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,代码行数:9,代码来源:exampledata.py


示例5: create_storable

    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,代码行数:12,代码来源:exampledata.py


示例6: _create_sale

    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,代码行数:53,代码来源:test_nfe.py


示例7: create_model

    def create_model(self, store):
        self._model_created = True
        sellable = Sellable(store=store)
        model = Product(store=store, sellable=sellable)
        no_storable = [Product.TYPE_WITHOUT_STOCK, Product.TYPE_PACKAGE]
        if not self._product_type in no_storable:
            storable = Storable(product=model, store=store)

        if self._product_type == Product.TYPE_BATCH:
            storable.is_batch = True
        elif self._product_type == Product.TYPE_WITHOUT_STOCK:
            model.manage_stock = False
        elif self._product_type == Product.TYPE_CONSIGNED:
            model.consignment = True
        elif self._product_type == Product.TYPE_GRID:
            model.is_grid = True
            # Configurable products should not manage stock
            model.manage_stock = False
        elif self._product_type == Product.TYPE_PACKAGE:
            model.is_package = True
            # Package products should not manage stock
            model.manage_stock = False

        if self._template is not None:
            sellable.tax_constant = self._template.sellable.tax_constant
            sellable.unit = self._template.sellable.unit
            sellable.category = self._template.sellable.category
            sellable.base_price = self._template.sellable.base_price
            sellable.cost = self._template.sellable.cost

            model.manufacturer = self._template.manufacturer
            model.brand = self._template.brand
            model.family = self._template.family
            model.ncm = self._template.ncm
            model.icms_template = self._template.icms_template
            model.ipi_template = self._template.ipi_template

            for product_attr in self._template.attributes:
                ProductAttribute(store=self.store,
                                 product_id=model.id,
                                 attribute_id=product_attr.attribute.id)
            for supplier_info in self._template.suppliers:
                ProductSupplierInfo(
                    store=self.store,
                    product=model,
                    supplier=supplier_info.supplier)
        else:
            sellable.tax_constant_id = sysparam.get_object_id(
                'DEFAULT_PRODUCT_TAX_CONSTANT')
            sellable.unit_id = sysparam.get_object_id('SUGGESTED_UNIT')

        return model
开发者ID:Guillon88,项目名称:stoq,代码行数:52,代码来源:producteditor.py


示例8: create_storable

 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,代码行数:13,代码来源:exampledata.py


示例9: create_loan_item

 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,代码行数:14,代码来源:exampledata.py


示例10: create_inventory_item

 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,代码行数:14,代码来源:exampledata.py


示例11: create_transfer_order_item

 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,代码行数:15,代码来源:exampledata.py


示例12: create_product

    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,代码行数:15,代码来源:exampledata.py


示例13: _get_storables

 def _get_storables(self):
     self._current_branch = self.model.branch
     # Cache this data, to avoid more queries when building the list of storables.
     self._categories = list(self.store.find(SellableCategory))
     data = Storable.get_initial_stock_data(self.store, self.model.branch)
     for sellable, product, storable in data:
         yield _TemporaryStorableItem(sellable, product, storable)
开发者ID:Guillon88,项目名称:stoq,代码行数:7,代码来源:initialstockdialog.py


示例14: create_inventory_item

 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,代码行数:16,代码来源:exampledata.py


示例15: create_model

    def create_model(self, store):
        self._model_created = True
        sellable = Sellable(store=store)
        sellable.tax_constant_id = sysparam.get_object_id('DEFAULT_PRODUCT_TAX_CONSTANT')
        sellable.unit_id = sysparam.get_object_id('SUGGESTED_UNIT')
        model = Product(store=store, sellable=sellable)
        if self._product_type != Product.TYPE_WITHOUT_STOCK:
            storable = Storable(product=model, store=store)

        if self._product_type == Product.TYPE_BATCH:
            storable.is_batch = True
        elif self._product_type == Product.TYPE_WITHOUT_STOCK:
            model.manage_stock = False
        elif self._product_type == Product.TYPE_CONSIGNED:
            model.consignment = True

        return model
开发者ID:igorferreira,项目名称:stoq,代码行数:17,代码来源:producteditor.py


示例16: testCanRemove

    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,代码行数:45,代码来源:test_product.py


示例17: create_product

    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,代码行数:18,代码来源:exampledata.py


示例18: _create_sale

    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)

        # [0] - Description
        # [1] - Code
        # [2] - Price
        # [3] - Quantity
        for data in [(u"Laranja", u"1", Decimal(1), Decimal(10)),
                     (u"Limão", u"2", Decimal('0.5'), Decimal(15)),
                     (u"Abacaxi", u"3", Decimal(3), Decimal(1)),
                     (u"Cenoura", u"4", Decimal('1.5'), Decimal(6)),
                     (u"Pêssego", u"5", Decimal('3.5'), Decimal(3))]:
            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.add_sellable(sellable, data[3])

        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:Joaldino,项目名称:stoq,代码行数:38,代码来源:test_nfe.py


示例19: test_get_storables_without_stock_item

    def test_get_storables_without_stock_item(self):
        self.clean_domain([StockTransactionHistory, ProductStockItem, Storable])

        s0_without_stock = self.create_storable()

        b1 = self.create_branch()
        s1_with_stock = self.create_storable(branch=b1, stock=1)
        s1_without_stock = self.create_storable(branch=b1)

        b2 = self.create_branch()
        s2_with_stock = self.create_storable(branch=b2, stock=1)
        s2_without_stock = self.create_storable(branch=b2)

        # All but s1_with_stock should be here
        self.assertEqual(
            set(Storable.get_storables_without_stock_item(self.store, b1)),
            set([s0_without_stock, s1_without_stock,
                 s2_without_stock, s2_with_stock]))
        # All but s2_with_stock should be here
        self.assertEqual(
            set(Storable.get_storables_without_stock_item(self.store, b2)),
            set([s0_without_stock, s2_without_stock,
                 s1_without_stock, s1_with_stock]))
开发者ID:LeonamSilva,项目名称:stoq,代码行数:23,代码来源:test_product.py


示例20: _get_storables

 def _get_storables(self):
     for s in Storable.get_storables_without_stock_item(self.store,
                                                        self._branch):
         yield _TemporaryStorableItem(s)
开发者ID:leandrorchaves,项目名称:stoq,代码行数:4,代码来源:initialstockdialog.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python production.ProductionProducedItem类代码示例发布时间:2022-05-27
下一篇:
Python product.ProductHistory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap