Пример #1
0
    def _create_domain(self):
        self.clean_domain([SaleItem])

        branch = get_current_branch(self.store)
        self.today = localtoday()

        product = self.create_product()
        storable = Storable(store=self.store, product=product)
        ProductStockItem(storable=storable,
                         branch=branch,
                         quantity=5,
                         store=self.store)
        product.sellable.code = u'1'
        product.sellable.description = u'Luvas'

        product2 = self.create_product()
        storable2 = Storable(store=self.store, product=product2)
        ProductStockItem(storable=storable2,
                         branch=branch,
                         quantity=5,
                         store=self.store)
        product2.sellable.code = u'2'
        product2.sellable.description = u'Botas'

        # Sale
        sale = self.create_sale(branch=branch)
        sale.identifier = 123
        sale.open_date = self.today
        sale.add_sellable(product.sellable, 3)
        sale.add_sellable(product2.sellable, 5)
        sale.order()
        self.add_payments(sale, date=self.today)
        sale.confirm()
Пример #2
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')
Пример #3
0
    def test_search(self):
        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'65432'
        product.sellable.description = u'Camiseta'
        self.create_product_component(product=product)

        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'54321'
        product.sellable.description = u'Luva'
        product.sellable.status = Sellable.STATUS_CLOSED
        self.create_product_component(product=product)

        search = ProductionProductSearch(self.store)

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

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

        search.set_searchbar_search_string('')
        search.branch_filter.set_state(api.get_current_branch(self.store).id)
        search.search.refresh()
        self.check_search(search, 'production-product-branch-filter')

        search.branch_filter.set_state(None)
        search.status_filter.set_state(Sellable.STATUS_AVAILABLE)
        search.search.refresh()
        self.check_search(search, 'production-product-status-filter')
Пример #4
0
    def test_purchased_items_search(self):
        branch = api.get_current_branch(self.store)
        order = self.create_purchase_order(branch=branch)
        item = self.create_purchase_order_item(order=order)
        item.sellable.description = u'Camisa listrada'
        item.quantity = 5
        item.quantity_received = 3
        item.order.open_date = datetime.datetime(2012, 1, 1)
        item.order.status = PurchaseOrder.ORDER_CONFIRMED
        storable = self.create_storable(item.sellable.product)
        ProductStockItem(quantity=item.quantity,
                         branch=branch,
                         storable=storable,
                         store=self.store)

        branch = self.store.find(Branch, Branch.id != branch.id).any()
        order = self.create_purchase_order(branch=branch)
        item = self.create_purchase_order_item(order=order)
        item.sellable.description = u'Camisa bordada'
        item.quantity = 4
        item.quantity_received = 2
        item.order.open_date = datetime.datetime(2012, 2, 2)
        item.order.status = PurchaseOrder.ORDER_CONFIRMED
        storable = self.create_storable(item.sellable.product)
        ProductStockItem(quantity=item.quantity,
                         branch=branch,
                         storable=storable,
                         store=self.store)

        search = PurchasedItemsSearch(self.store)

        search.search.refresh()
        search.branch_filter.set_state(None)
        self.check_search(search, 'purchase-no-filter')

        search.set_searchbar_search_string('bor')
        search.search.refresh()
        self.check_search(search, 'purchase-string-filter')

        search.set_searchbar_search_string('')
        search.branch_filter.set_state(api.get_current_branch(self.store).id)
        search.search.refresh()
        self.check_search(search, 'purchase-branch-filter')
Пример #5
0
 def create_product_stock_item(self, stock_cost=0, quantity=0,
                               branch=None, storable=None):
     from stoqlib.domain.product import ProductStockItem
     if storable is None:
         storable = self.create_storable()
     return ProductStockItem(stock_cost=stock_cost,
                             quantity=quantity,
                             branch=get_current_branch(store=self.store),
                             storable=storable,
                             store=self.store)
Пример #6
0
    def _create_domain(self):
        branch = get_current_branch(self.store)

        product = self.create_product()
        storable = Storable(store=self.store, product=product)
        ProductStockItem(store=self.store,
                         storable=storable,
                         branch=branch,
                         quantity=2)
        product.brand = u''
        product.sellable.code = u'1'
        product.sellable.description = u'Luvas'

        product2 = self.create_product()
        storable2 = Storable(store=self.store, product=product2)
        ProductStockItem(store=self.store,
                         storable=storable2,
                         branch=branch,
                         quantity=4)
        product2.brand = u'brand'
        product.sellable.code = u'2'
        product.sellable.description = u'Botas'
Пример #7
0
    def _create_domain(self):
        self.today = datetime.date.today()

        branch = get_current_branch(self.store)

        product = self.create_product()
        storable = Storable(store=self.store, product=product)
        ProductStockItem(store=self.store,
                         storable=storable,
                         branch=branch,
                         quantity=2)
        product.sellable.code = u'1'
        product.sellable.description = u'Luvas'
        product.sellable.status = Sellable.STATUS_CLOSED

        product = self.create_product()
        storable = Storable(store=self.store, product=product)
        ProductStockItem(store=self.store,
                         storable=storable,
                         branch=branch,
                         quantity=4)
        product.sellable.code = u'2'
        product.sellable.description = u'Botas'
        product.sellable.status = Sellable.STATUS_CLOSED