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


Python sellable.Sellable类代码示例

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


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

示例1: test_with_unblocked_sellables_query

    def test_with_unblocked_sellables_query(self):
        # This is used in the purchase wizard and breaks storm
        from stoqlib.domain.sellable import Sellable

        p1 = self.create_product()
        supplier = self.create_supplier()

        # Product should appear when querying without a supplier
        query = Sellable.get_unblocked_sellables_query(self.store)
        results = self.store.find(ProductFullStockView, query)
        self.assertTrue(p1.id in [p.product_id for p in results])

        # But should not appear when querying with a supplier
        # When querying using the supplier, we should use the
        # ProductFullStockSupplierView instead.
        query = Sellable.get_unblocked_sellables_query(self.store, supplier=supplier)
        results = self.store.find(ProductFullStockItemSupplierView, query)
        self.assertFalse(p1.id in [p.id for p in results])

        # Now relate the two
        ProductSupplierInfo(store=self.store, supplier=supplier, product=p1, is_main_supplier=True)

        # And it should appear now
        query = Sellable.get_unblocked_sellables_query(self.store, supplier=supplier)
        results = self.store.find(ProductFullStockItemSupplierView, query)
        self.assertTrue(p1.id in [s.product_id for s in results])

        # But should not appear for a different supplier
        other_supplier = self.create_supplier()
        query = Sellable.get_unblocked_sellables_query(self.store, supplier=other_supplier)
        results = self.store.find(ProductFullStockItemSupplierView, query)
        self.assertFalse(p1.id in [s.product_id for s in results])
开发者ID:rg3915,项目名称:stoq,代码行数:32,代码来源:test_views.py

示例2: test_get_available_sellables_query

    def test_get_available_sellables_query(self):
        # Sellable and query without supplier
        sellable = self.create_sellable()
        self.create_storable(product=sellable.product,
                             branch=self.create_branch())

        self.assertIn(
            sellable,
            self.store.find(Sellable,
                            Sellable.get_available_sellables_query(self.store)))

        sellable.close()
        self.assertNotIn(
            sellable,
            self.store.find(Sellable,
                            Sellable.get_available_sellables_query(self.store)))

        delivery_sellable = sysparam(self.store).DELIVERY_SERVICE.sellable
        delivery_sellable.status = Sellable.STATUS_AVAILABLE
        # Deliveries are treated differently, that's why they should
        # not be present here
        self.assertNotIn(
            sellable,
            self.store.find(Sellable,
                            Sellable.get_available_sellables_query(self.store)))
开发者ID:LeonamSilva,项目名称:stoq,代码行数:25,代码来源:test_sellable.py

示例3: test_get_unblocked_sellables

    def test_get_unblocked_sellables(self):
        # Sellable and query without supplier
        sellable = self.create_sellable()
        available = Sellable.get_unblocked_sellables(self.store)
        self.assertTrue(sellable in list(available))

        # Sellable without supplier, but querying with one
        supplier = self.create_supplier()
        available = Sellable.get_unblocked_sellables(self.store,
                                                     supplier=supplier)
        self.assertFalse(sellable in list(available))

        # Relate the two
        from stoqlib.domain.product import ProductSupplierInfo
        ProductSupplierInfo(store=self.store,
                            supplier=supplier,
                            product=sellable.product,
                            is_main_supplier=True)

        # Now the sellable should appear in the results
        available = Sellable.get_unblocked_sellables(self.store,
                                                     supplier=supplier)
        self.assertTrue(sellable in list(available))

        # Now the sellable should appear in the results
        storable = Storable(product=sellable.product, store=self.store)
        available = Sellable.get_unblocked_sellables(self.store,
                                                     storable=storable)
        self.assertTrue(sellable in list(available))
开发者ID:hackedbellini,项目名称:stoq,代码行数:29,代码来源:test_sellable.py

示例4: test_get_unblocked_by_category

    def test_get_unblocked_by_category(self):
        s1 = self.create_sellable()
        s2 = self.create_sellable()
        s3 = self.create_sellable()

        c1 = self.create_sellable_category()
        c2 = self.create_sellable_category()
        s1.category = c1
        s2.category = c2

        self.assertEqual(
            set([s1, s2, s3]),
            set(Sellable.get_unblocked_by_categories(
                self.store, [c1, c2], include_uncategorized=True)))

        self.assertEqual(
            set([s1, s3]),
            set(Sellable.get_unblocked_by_categories(
                self.store, [c1], include_uncategorized=True)))

        self.assertEqual(
            set([s1, s3]),
            set(Sellable.get_unblocked_by_categories(
                self.store, [c1], include_uncategorized=True)))

        self.assertEqual(
            set([s1]),
            set(Sellable.get_unblocked_by_categories(
                self.store, [c1], include_uncategorized=False)))

        self.assertEqual(
            set([s3]),
            set(Sellable.get_unblocked_by_categories(
                self.store, [], include_uncategorized=True)))
开发者ID:LeonamSilva,项目名称:stoq,代码行数:34,代码来源:test_sellable.py

示例5: create_model

 def create_model(self, store):
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, self.store)
     sellable = Sellable(description=u"", price=currency(0), store=store)
     sellable.tax_constant = tax_constant
     sellable.unit_id = sysparam.get_object_id("SUGGESTED_UNIT")
     model = Service(sellable=sellable, store=store)
     return model
开发者ID:EasyDevSolutions,项目名称:stoq,代码行数:7,代码来源:serviceeditor.py

示例6: _update_default_sellable_code

 def _update_default_sellable_code(self, category=None):
     if category:
         query = (Sellable.category_id == category.id)
         code = Sellable.get_max_value(self.store, Sellable.code, query=query)
     else:
         code = Sellable.get_max_value(self.store, Sellable.code)
     self.code.update(next_value_for(code))
开发者ID:hackedbellini,项目名称:stoq,代码行数:7,代码来源:sellableeditor.py

示例7: create_model

 def create_model(self, store):
     self._model_created = True
     tax_constant = sysparam(store).DEFAULT_PRODUCT_TAX_CONSTANT
     sellable = Sellable(store=store)
     sellable.tax_constant = tax_constant
     sellable.unit = sysparam(self.store).SUGGESTED_UNIT
     model = Product(store=store, sellable=sellable)
     Storable(product=model, store=store)
     return model
开发者ID:romaia,项目名称:stoq,代码行数:9,代码来源:producteditor.py

示例8: create_service

    def create_service(self, description=u"Description", price=10):
        from stoqlib.domain.sellable import Sellable, SellableTaxConstant
        from stoqlib.domain.service import Service

        tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, self.store)
        sellable = Sellable(price=price, description=description, store=self.store)
        sellable.tax_constant = tax_constant
        service = Service(sellable=sellable, store=self.store)
        return service
开发者ID:rg3915,项目名称:stoq,代码行数:9,代码来源:exampledata.py

示例9: create_model

 def create_model(self, store):
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, self.store)
     sellable = Sellable(description=u'',
                         price=currency(0),
                         store=store)
     sellable.status = Sellable.STATUS_AVAILABLE
     sellable.tax_constant = tax_constant
     sellable.unit = sysparam(self.store).SUGGESTED_UNIT
     model = Service(sellable=sellable, store=store)
     return model
开发者ID:romaia,项目名称:stoq,代码行数:10,代码来源:serviceeditor.py

示例10: 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)
     # FIXME: Instead of creating and then removing, we should only create
     # the Storable if the user chooses to do so, but due to the way the
     # editor is implemented, it is not that easy. Change this once we write
     # the new product editor.
     Storable(product=model, store=store)
     return model
开发者ID:pkaislan,项目名称:stoq,代码行数:12,代码来源:producteditor.py

示例11: test_category_name

 def test_category_name(self):
     sellable = Sellable(category=None,
                         cost=50,
                         description=u"Test",
                         price=currency(100),
                         store=self.store)
     sellable.max_discount = 0
     cat = self.create_client_category(u'Cat 1')
     cat_price = ClientCategoryPrice(sellable=sellable, category=cat,
                                     price=150, max_discount=0,
                                     store=self.store)
     self.assertEqual(cat_price.category_name, u'Cat 1')
开发者ID:hackedbellini,项目名称:stoq,代码行数:12,代码来源:test_sellable.py

示例12: process_one

    def process_one(self, data, fields, store):
        tax = store.fetch(self.tax_constant)
        sellable = Sellable(store=store,
                            description=data.description,
                            price=int(data.price),
                            cost=int(data.cost))
        sellable.tax_constant = tax
        sellable.code = data.barcode
        sellable.barcode = data.barcode

        Service(sellable=sellable,
                store=store)
开发者ID:LeonamSilva,项目名称:stoq,代码行数:12,代码来源:serviceimporter.py

示例13: test_markup

    def test_markup(self):
        sellable = Sellable(category=None,
                            cost=0,
                            store=self.store)
        cat = self.create_client_category(u'Cat 1')
        cat_price = ClientCategoryPrice(sellable=sellable, category=cat,
                                        price=150, max_discount=0,
                                        store=self.store)
        self.assertEqual(cat_price.markup, 0)
        sellable.cost = 10
        self.assertEqual(cat_price.markup, 1400)

        cat_price.markup = 10
开发者ID:hackedbellini,项目名称:stoq,代码行数:13,代码来源:test_sellable.py

示例14: create_delivery_service

 def create_delivery_service(self):
     from stoqlib.domain.sellable import (Sellable,
                                          SellableTaxConstant)
     from stoqlib.domain.service import Service
     key = u"DELIVERY_SERVICE"
     store = new_store()
     tax_constant = SellableTaxConstant.get_by_type(TaxType.SERVICE, store)
     sellable = Sellable(description=_(u'Delivery'),
                         store=store)
     sellable.tax_constant = tax_constant
     service = Service(sellable=sellable, store=store)
     self._set_schema(key, service.id)
     store.commit(close=True)
开发者ID:rosalin,项目名称:stoq,代码行数:13,代码来源:parameters.py

示例15: test_price_on_sale_price_getter

    def test_price_on_sale_price_getter(self):
        sellable = Sellable(category=self._category,
                            cost=50,
                            description=u"Test",
                            price=100,
                            store=self.store)

        self.assertEquals(sellable.price, 100)
        sellable.on_sale_price = 80
        self.assertEquals(sellable.price, 80)

        # - Old promotion
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(2002, 1, 1)
        self.assertEquals(sellable.price, 100)

        # - Future promotion
        sellable.on_sale_start_date = localdate(3001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        self.assertEquals(sellable.price, 100)

        # Current promotion
        sellable.on_sale_start_date = localdate(2001, 1, 1)
        sellable.on_sale_end_date = localdate(3002, 1, 1)
        self.assertEquals(sellable.price, 80)
开发者ID:pkaislan,项目名称:stoq,代码行数:25,代码来源:test_sellable.py


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