Esempio n. 1
0
 def test_product_report(self):
     from stoq.lib.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))
Esempio n. 2
0
    def test_product_search(self):
        from stoq.lib.gui.search.productsearch import ProductSearch
        from stoq.lib.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')
Esempio n. 3
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)
Esempio n. 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')
Esempio n. 5
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')
Esempio n. 6
0
 def _show_search(self):
     search = ProductSearch(self.store)
     search.search.refresh()
     search.results.select(search.results[0])
     return search
Esempio n. 7
0
 def test_search_without_price_column(self):
     search = ProductSearch(self.store, hide_price_column=True)
     self.check_search(search, 'product-search-without-price')
Esempio n. 8
0
 def __init__(self, store, hide_footer=True, hide_toolbar=True):
     ProductSearch.__init__(self, store, hide_footer=hide_footer,
                            hide_toolbar=hide_toolbar)