예제 #1
0
 def test_product_report(self):
     from stoqlib.gui.search.productsearch import ProductSearch
     search = ProductSearch(self.store)
     search.width = 1000
     # the order_by clause is only needed by the test
     products = self.store.find(ProductFullStockView)
     search.results.add_list(products, clear=True)
     self._diff_expected(ProductReport, 'product-report',
                         search.results, list(search.results))
예제 #2
0
 def testProductReport(self):
     from stoqlib.gui.search.productsearch import ProductSearch
     search = ProductSearch(self.store)
     search.width = 1000
     # the order_by clause is only needed by the test
     products = self.store.find(ProductFullStockView).order_by(ProductFullStockView.id)
     search.results.add_list(products, clear=True)
     self._diff_expected(ProductReport, 'product-report',
                         search.results, list(search.results))
예제 #3
0
파일: test_reporting.py 프로젝트: stoq/stoq
    def test_product_report(self):
        from stoqlib.gui.search.productsearch import ProductSearch

        search = ProductSearch(self.store)
        search.width = 1000
        # the order_by clause is only needed by the test
        products = self.store.find(ProductFullStockView)
        search.results.clear()
        search.results.search_completed(products)
        self._diff_expected(ProductReport, "product-report", search.results, list(search.results))
예제 #4
0
    def test_search(self):
        self.clean_domain([StockTransactionHistory, ProductSupplierInfo,
                           ProductStockItem, Storable, Product])

        branches = list(self.store.find(Branch))

        product = self.create_product()
        storable = self.create_storable(product=product)
        self.create_product_stock_item(
            storable=storable, branch=branches[0], quantity=1)
        self.create_product_stock_item(
            storable=storable, branch=branches[1], quantity=2)
        product.sellable.code = u'1'
        product.sellable.description = u'Luvas'
        product.brand = u'Rawlings'
        product.internal_use = True

        product = self.create_product()
        storable = self.create_storable(product=product)
        self.create_product_stock_item(
            storable=storable, branch=branches[0], quantity=3)
        self.create_product_stock_item(
            storable=storable, branch=branches[1], quantity=4)
        product.sellable.code = u'2'
        product.sellable.description = u'Botas'
        product.sellable.status = Sellable.STATUS_CLOSED
        product.brand = u'Timberland'

        search = ProductSearch(self.store)

        search.search.refresh()
        self.check_search(search, 'product-no-filter')

        search.set_searchbar_search_string('bot')
        search.search.refresh()
        self.check_search(search, 'product-string-filter')

        search.set_searchbar_search_string('')
        search.status_filter.set_state(Sellable.STATUS_AVAILABLE)
        search.search.refresh()
        self.check_search(search, 'product-status-filter')

        search.status_filter.set_state(None)
        search.branch_filter.set_state(branches[0].id)
        search.search.refresh()
        self.check_search(search, 'product-branch-filter')
예제 #5
0
    def testSearch(self):
        self.clean_domain([ProductSupplierInfo, ProductStockItem, Storable,
                           Product])

        branches = self.store.find(Branch)

        product = self.create_product()
        storable = self.create_storable(product=product)
        ProductStockItem(quantity=1, branch=branches[0], storable=storable,
                         store=self.store)
        ProductStockItem(quantity=2, branch=branches[1], storable=storable,
                         store=self.store)
        product.sellable.code = u'1'
        product.sellable.description = u'Luvas'
        product.sellable.status = Sellable.STATUS_AVAILABLE

        product = self.create_product()
        storable = self.create_storable(product=product)
        ProductStockItem(quantity=3, branch=branches[0], storable=storable,
                         store=self.store)
        ProductStockItem(quantity=4, branch=branches[1], storable=storable,
                         store=self.store)
        product.sellable.code = u'2'
        product.sellable.description = u'Botas'
        product.sellable.status = Sellable.STATUS_UNAVAILABLE

        search = ProductSearch(self.store)

        search.search.refresh()
        self.check_search(search, 'product-no-filter')

        search.set_searchbar_search_string('bot')
        search.search.refresh()
        self.check_search(search, 'product-string-filter')

        search.set_searchbar_search_string('')
        search.status_filter.set_state(Sellable.STATUS_AVAILABLE)
        search.search.refresh()
        self.check_search(search, 'product-status-filter')

        search.status_filter.set_state(None)
        search.branch_filter.set_state(branches[0].id)
        search.search.refresh()
        self.check_search(search, 'product-branch-filter')
예제 #6
0
    def test_product_search(self):
        from stoqlib.gui.search.productsearch import ProductSearch
        from stoqlib.gui.search.costcentersearch import CostCenterSearch
        # ProductSearch should have new columns
        search = ProductSearch(self.store)
        search.search.refresh()
        self.check_search(search, 'search-optical-product-search')

        # Cost center search does not use a viewable, so it should not have columns
        assert not issubclass(CostCenterSearch.search_spec, Viewable)
        search = CostCenterSearch(self.store)
        search.search.refresh()
        self.check_search(search, 'search-optical-cost-center-search')
예제 #7
0
    def test_run_editor(self, run_dialog, new_store):
        run_dialog.return_value = True
        new_store.return_value = self.store
        dialog = ProductSearch(store=self.store)
        dialog.search.refresh()
        dialog.results.select(dialog.results[0])
        product = dialog.results[0].product

        with mock.patch.object(self.store, 'commit'):
            with mock.patch.object(self.store, 'close'):
                self.click(dialog._toolbar.edit_button)
                run_dialog.assert_called_once_with(ProductEditor, dialog,
                                                   self.store, product,
                                                   visual_mode=False)
예제 #8
0
    def test_search(self):
        self.clean_domain([
            StockTransactionHistory, ProductSupplierInfo, ProductStockItem,
            Storable, Product
        ])

        branches = self.store.find(Branch)

        product = self.create_product()
        storable = self.create_storable(product=product)
        ProductStockItem(quantity=1,
                         branch=branches[0],
                         storable=storable,
                         store=self.store)
        ProductStockItem(quantity=2,
                         branch=branches[1],
                         storable=storable,
                         store=self.store)
        product.sellable.code = u'1'
        product.sellable.description = u'Luvas'

        product = self.create_product()
        storable = self.create_storable(product=product)
        ProductStockItem(quantity=3,
                         branch=branches[0],
                         storable=storable,
                         store=self.store)
        ProductStockItem(quantity=4,
                         branch=branches[1],
                         storable=storable,
                         store=self.store)
        product.sellable.code = u'2'
        product.sellable.description = u'Botas'
        product.sellable.status = Sellable.STATUS_CLOSED

        search = ProductSearch(self.store)

        search.search.refresh()
        self.check_search(search, 'product-no-filter')

        search.set_searchbar_search_string('bot')
        search.search.refresh()
        self.check_search(search, 'product-string-filter')

        search.set_searchbar_search_string('')
        search.status_filter.set_state(Sellable.STATUS_AVAILABLE)
        search.search.refresh()
        self.check_search(search, 'product-status-filter')

        search.status_filter.set_state(None)
        search.branch_filter.set_state(branches[0].id)
        search.search.refresh()
        self.check_search(search, 'product-branch-filter')
예제 #9
0
    def test_search(self):
        self.clean_domain([
            StockTransactionHistory, ProductSupplierInfo, ProductStockItem,
            Storable, Product
        ])

        branches = list(self.store.find(Branch))

        product = self.create_product()
        storable = self.create_storable(product=product)
        self.create_product_stock_item(storable=storable,
                                       branch=branches[0],
                                       quantity=1)
        self.create_product_stock_item(storable=storable,
                                       branch=branches[1],
                                       quantity=2)
        product.sellable.code = u'1'
        product.sellable.description = u'Luvas'
        product.brand = u'Rawlings'
        product.internal_use = True

        product = self.create_product()
        storable = self.create_storable(product=product)
        self.create_product_stock_item(storable=storable,
                                       branch=branches[0],
                                       quantity=3)
        self.create_product_stock_item(storable=storable,
                                       branch=branches[1],
                                       quantity=4)
        product.sellable.code = u'2'
        product.sellable.description = u'Botas'
        product.sellable.status = Sellable.STATUS_CLOSED
        product.brand = u'Timberland'

        search = ProductSearch(self.store)

        search.search.refresh()
        self.check_search(search, 'product-no-filter')

        search.set_searchbar_search_string('bot')
        search.search.refresh()
        self.check_search(search, 'product-string-filter')

        search.set_searchbar_search_string('')
        search.status_filter.set_state(Sellable.STATUS_AVAILABLE)
        search.search.refresh()
        self.check_search(search, 'product-status-filter')

        search.status_filter.set_state(None)
        search.branch_filter.set_state(branches[0].id)
        search.search.refresh()
        self.check_search(search, 'product-branch-filter')
예제 #10
0
    def test_search_dialog_setup_search(self):
        class ProductSearchExtention(SearchExtension):
            spec_attributes = dict(ncm=Product.ncm)

            def get_columns(self):
                return [SearchColumn('ncm', title='NCM', data_type=str)]

        def _setup_search(dialog):
            return dialog.add_extension(ProductSearchExtention())

        # At leat one product should have a NCM value, so we can verify the
        # results.
        product = self.store.find(Product).order_by(Product.te_id).first()
        product.ncm = u'12345678'

        SearchDialogSetupSearchEvent.connect(_setup_search)
        dialog = ProductSearch(self.store)
        dialog.search.refresh()
        self.check_search(dialog, 'product-search-extended')
예제 #11
0
 def __init__(self, store, hide_footer=True, hide_toolbar=True):
     ProductSearch.__init__(self, store, hide_footer=hide_footer,
                            hide_toolbar=hide_toolbar)
예제 #12
0
 def __init__(self, store, hide_footer=True, hide_toolbar=True):
     ProductSearch.__init__(self,
                            store,
                            hide_footer=hide_footer,
                            hide_toolbar=hide_toolbar)
예제 #13
0
 def _show_search(self):
     search = ProductSearch(self.store)
     search.search.refresh()
     search.results.select(search.results[0])
     return search
예제 #14
0
 def test_search_without_price_column(self):
     search = ProductSearch(self.store, hide_price_column=True)
     self.check_search(search, 'product-search-without-price')