Exemple #1
0
 def test_edit_purchase_without_open_date(self):
     purchase_order = self.create_purchase_order()
     self.create_purchase_order_item(purchase_order)
     purchase_order.status = PurchaseOrder.ORDER_PENDING
     self.wizard = PurchaseWizard(self.store, purchase_order)
     start_step = self.wizard.get_current_step()
     start_step.open_date.update(None)
     self.assertEqual(start_step.open_date.mandatory, True)
     self.assertNotSensitive(self.wizard, ['next_button'])
    def test_create_without_active_supplier(self):
        # Inactivating all the suppliers, so they wont show on PurchaseWizard
        suppliers = self.store.find(Supplier)
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_INACTIVE

        wizard = PurchaseWizard(self.store)
        step = wizard.get_current_step()
        self.assertEqual(step.edit_supplier.get_sensitive(), False)
        step.supplier.set_text('Invalid supplier')
        self.assertEqual(step.edit_supplier.get_sensitive(), False)

        # Activating the suppliers back
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_ACTIVE
Exemple #3
0
    def test_create_without_active_supplier(self):
        # Inactivating all the suppliers, so they wont show on PurchaseWizard
        suppliers = self.store.find(Supplier)
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_INACTIVE

        wizard = PurchaseWizard(self.store)
        step = wizard.get_current_step()
        self.assertEqual(step.edit_supplier.get_sensitive(), False)
        step.supplier.set_text('Invalid supplier')
        self.assertEqual(step.edit_supplier.get_sensitive(), False)

        # Activating the suppliers back
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_ACTIVE
    def test_create(self):
        # Allow creating purchases in the past.
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)

        self.wizard = PurchaseWizard(self.store)
        purchase_branch = self.create_branch()
        purchase_order = PurchaseOrder(branch=purchase_branch)
        sellable = self.create_sellable()
        purchase_order.add_item(sellable=sellable)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = localdate(2010, 1, 3).date()
        self._check_start_step('wizard-purchase-start-step')
        self._check_item_step('wizard-purchase-item-step')
        self._check_payment_step('wizard-purchase-payment-step')

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        self.check_wizard(self.wizard, 'wizard-purchase-finish-step',
                          models=models)

        self.click(self.wizard.next_button)
Exemple #5
0
    def testCreateAndReceive(self):
        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = datetime.date(2010, 1, 3)
        self._check_start_step()
        self._check_item_step()
        self._check_payment_step()

        finish_step = self.wizard.get_current_step()
        finish_step.receive_now.set_active(True)

        self.click(self.wizard.next_button)

        receiving_step = self.wizard.get_current_step()
        receiving_step.invoice_slave.order_number.update("12345")
        receiving_step.invoice_slave.invoice_number.update(67890)

        self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

        self.click(self.wizard.next_button)

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        receive = self.wizard.receiving_model
        models.append(receive)
        models.extend(receive.get_items())
        for item in receive.get_items():
            models.extend(list(item.sellable.product_storable.get_stock_items()))

        self.check_wizard(self.wizard, 'wizard-purchase-done-received',
                          models=models)
Exemple #6
0
    def testCreate(self):
        wizard = PurchaseWizard(self.store)

        method = PaymentMethod.get_by_name(self.store, u'card')
        order = self.create_purchase_order()
        slave = CardMethodSlave(wizard, None, self.store, order, method,
                                Decimal(200))
        self.check_slave(slave, 'slave-card-method')
Exemple #7
0
    def testCreate(self):
        wizard = PurchaseWizard(self.store)

        method = PaymentMethod.get_by_name(self.store, u'check')
        order = self.create_purchase_order()
        order.identifier = 12345
        slave = CheckMethodSlave(wizard, None, self.store, order, method,
                                 Decimal(200))
        self.check_slave(slave, 'slave-check-method')
 def test_edit_purchase_without_open_date(self):
     purchase_order = self.create_purchase_order()
     self.create_purchase_order_item(purchase_order)
     purchase_order.status = PurchaseOrder.ORDER_PENDING
     self.wizard = PurchaseWizard(self.store, purchase_order)
     start_step = self.wizard.get_current_step()
     start_step.open_date.update(None)
     self.assertEqual(start_step.open_date.mandatory, True)
     self.assertNotSensitive(self.wizard, ['next_button'])
    def test_create_and_receive(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            self.wizard = PurchaseWizard(self.store)
            self.wizard.model.identifier = 12345
            self.wizard.model.open_date = localdate(2010, 1, 3).date()
            self._check_start_step()
            self._check_item_step()
            payment_step = self.wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self._check_payment_step()

            finish_step = self.wizard.get_current_step()
            finish_step.receive_now.set_active(True)
            self.wizard.model.expected_receival_date = localdate(2010, 1,
                                                                 4).date()

            self.wizard.enable_next()
            self.click(self.wizard.next_button)

            receiving_step = self.wizard.get_current_step()
            receiving_step.invoice_slave.identifier.set_text("12345")
            receiving_step.invoice_slave.invoice_number.update(67890)

            self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

            self.click(self.wizard.next_button)

            purchase = self.wizard.model
            models = [purchase]
            models.extend(purchase.get_items())
            models.extend(purchase.payments)
            models.append(purchase.group)

            receive = self.wizard.receiving_model
            models.append(receive)
            models.append(receive.receiving_invoice)
            models.extend(receive.get_items())
            for item in receive.get_items():
                models.extend(
                    list(item.sellable.product_storable.get_stock_items()))

            self.check_wizard(self.wizard,
                              'wizard-purchase-done-received',
                              models=models)
Exemple #10
0
    def test_check_payment(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=False):
            wizard = PurchaseWizard(self.store)

            method = PaymentMethod.get_by_name(self.store, u'check')
            order = self.create_purchase_order()
            order.identifier = 1234567
            CheckMethodSlave(wizard, None, self.store, order, method, Decimal(200))

            self.assertSensitive(wizard, ['next_button'])
Exemple #11
0
    def test_no_receive_now_for_batch_items(self):
        sellable = self.create_sellable()
        product = self.create_product()
        storable = self.create_storable(is_batch=True)
        storable.product = product
        sellable.product = product

        wizard = PurchaseWizard(self.store)
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.sellable_selected(sellable)
        self.click(step.add_sellable_button)
        self.click(wizard.next_button)

        self.click(wizard.next_button)

        step = wizard.get_current_step()
        self.assertNotVisible(step, ['receive_now'])
Exemple #12
0
    def test_no_receive_now_for_batch_items(self):
        sellable = self.create_sellable()
        product = self.create_product()
        storable = self.create_storable(is_batch=True)
        storable.product = product
        sellable.product = product

        wizard = PurchaseWizard(self.store)
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.sellable_selected(sellable)
        self.click(step.add_sellable_button)
        self.click(wizard.next_button)

        self.click(wizard.next_button)

        step = wizard.get_current_step()
        self.assertNotVisible(step, ['receive_now'])
Exemple #13
0
    def test_no_receive_now_for_batch_items(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            sellable = self.create_sellable()
            self.create_storable(product=sellable.product, is_batch=True)

            wizard = PurchaseWizard(self.store)
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            step.sellable_selected(sellable)
            self.click(step.add_sellable_button)
            self.click(wizard.next_button)

            payment_step = wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            self.assertNotVisible(step, ['receive_now'])
    def test_no_receive_now_for_batch_items(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            sellable = self.create_sellable()
            self.create_storable(product=sellable.product, is_batch=True)

            wizard = PurchaseWizard(self.store)
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            step.sellable_selected(sellable)
            self.click(step.add_sellable_button)
            self.click(wizard.next_button)

            payment_step = wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            self.assertNotVisible(step, ['receive_now'])
Exemple #15
0
    def test_create_with_param_mandatory_check_number_true(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            wizard = PurchaseWizard(self.store)

            method = PaymentMethod.get_by_name(self.store, u'money')
            order = self.create_purchase_order()
            order.identifier = 12345
            slave = MoneyMethodSlave(wizard, None, self.store, order, method,
                                     Decimal(200))
            self.assertEquals(
                slave.bank_first_check_number.get_property('mandatory'), False)
Exemple #16
0
    def test_purchase_package(self):
        package = self.create_product(description=u'Package', is_package=True)
        component = self.create_product(description=u'component')
        self.create_product_component(product=package, component=component)
        wizard = PurchaseWizard(self.store)

        wizard = PurchaseWizard(self.store)
        self.click(wizard.next_button)

        # Item step
        step = wizard.get_current_step()
        step.sellable_selected(package.sellable)
        self.click(step.add_sellable_button)

        klist = step.slave.klist
        klist.select(klist[0])
        self.assertSensitive(step.slave, ['delete_button'])
        selected = klist.get_selected_rows()
        child = klist.get_descendants(selected[0])
        klist.select(child)
        self.assertNotSensitive(step.slave, ['delete_button'])
    def test_purchase_package(self):
        package = self.create_product(description=u'Package', is_package=True)
        component = self.create_product(description=u'component')
        self.create_product_component(product=package, component=component)
        wizard = PurchaseWizard(self.store)

        wizard = PurchaseWizard(self.store)
        self.click(wizard.next_button)

        # Item step
        step = wizard.get_current_step()
        step.sellable_selected(package.sellable)
        self.click(step.add_sellable_button)

        klist = step.slave.klist
        klist.select(klist[0])
        self.assertSensitive(step.slave, ['delete_button'])
        selected = klist.get_selected_rows()
        child = klist.get_descendants(selected[0])
        klist.select(child)
        self.assertNotSensitive(step.slave, ['delete_button'])
Exemple #18
0
 def test_post_init(self):
     purchase_order = self.create_purchase_order()
     receiving_order = self.create_receiving_order(
         purchase_order=purchase_order)
     self.create_receiving_order_item(receiving_order=receiving_order)
     wizard = PurchaseWizard(store=self.store)
     finish_step = FinishPurchaseStep(model=wizard.model,
                                      store=self.store,
                                      wizard=wizard)
     sellable = self.create_sellable()
     purchase_item = purchase_order.add_item(sellable=sellable)
     receiving_order.add_purchase_item(purchase_item)
     finish_step.post_init()
Exemple #19
0
    def testCreate(self):
        # Allow creating purchases in the past.
        sysparam(self.store).update_parameter(u"ALLOW_OUTDATED_OPERATIONS",
                                              u"1")

        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = localdate(2010, 1, 3).date()
        self._check_start_step('wizard-purchase-start-step')
        self._check_item_step('wizard-purchase-item-step')
        self._check_payment_step('wizard-purchase-payment-step')

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        self.check_wizard(self.wizard,
                          'wizard-purchase-finish-step',
                          models=models)

        self.click(self.wizard.next_button)
Exemple #20
0
    def test_installments(self):
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
        wizard = PurchaseWizard(self.store)

        method = PaymentMethod.get_by_name(self.store, u'bill')
        order = self.create_purchase_order()
        order.identifier = 12345

        slave = BillMethodSlave(wizard, None, self.store, order, method,
                                Decimal(200), localdate(2012, 1, 1).date())
        self.check_slave(slave, 'slave-bill-method-1-installments')

        slave.installments_number.update(2)
        self.check_slave(slave, 'slave-bill-method-2-installments')
Exemple #21
0
    def test_outdated(self):
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', False)
        wizard = PurchaseWizard(self.store)

        method = PaymentMethod.get_by_name(self.store, u'bill')
        order = self.create_purchase_order()

        today = localtoday().date()
        slave = BillMethodSlave(wizard, None, self.store, order, method,
                                Decimal(200), today)
        self.assertValid(slave, ['first_duedate'])

        slave.first_duedate.update(datetime.date(2012, 1, 1))
        self.assertInvalid(slave, ['first_duedate'])
Exemple #22
0
    def testInstallments(self):
        wizard = PurchaseWizard(self.store)

        method = PaymentMethod.get_by_name(self.store, u'card')
        order = self.create_purchase_order()
        slave = CardMethodSlave(wizard, None, self.store, order, method,
                                Decimal(200))

        # Select a option for multiple installments
        for radio in slave.types_box.get_children():
            if radio.get_label() == 'Credit Card Installments Store':
                break
        radio.set_active(True)

        self.check_slave(slave, 'slave-card-installments-store')
    def test_create_and_receive(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            self.wizard = PurchaseWizard(self.store)
            self.wizard.model.identifier = 12345
            self.wizard.model.open_date = localdate(2010, 1, 3).date()
            self._check_start_step()
            self._check_item_step()
            payment_step = self.wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self._check_payment_step()

            finish_step = self.wizard.get_current_step()
            finish_step.receive_now.set_active(True)
            self.wizard.model.expected_receival_date = localdate(2010, 1, 4).date()

            self.wizard.enable_next()
            self.click(self.wizard.next_button)

            receiving_step = self.wizard.get_current_step()
            receiving_step.invoice_slave.identifier.set_text("12345")
            receiving_step.invoice_slave.invoice_number.update(67890)

            self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

            self.click(self.wizard.next_button)

            purchase = self.wizard.model
            models = [purchase]
            models.extend(purchase.get_items())
            models.extend(purchase.payments)
            models.append(purchase.group)

            receive = self.wizard.receiving_model
            models.append(receive)
            models.append(receive.receiving_invoice)
            models.extend(receive.get_items())
            for item in receive.get_items():
                models.extend(
                    list(item.sellable.product_storable.get_stock_items()))

            self.check_wizard(self.wizard, 'wizard-purchase-done-received',
                              models=models)
    def testCreate(self):
        # Allow creating purchases in the past.
        sysparam(self.store).update_parameter(
            u"ALLOW_OUTDATED_OPERATIONS", u"1")

        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = localdate(2010, 1, 3).date()
        self._check_start_step('wizard-purchase-start-step')
        self._check_item_step('wizard-purchase-item-step')
        self._check_payment_step('wizard-purchase-payment-step')

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        self.check_wizard(self.wizard, 'wizard-purchase-finish-step',
                          models=models)

        self.click(self.wizard.next_button)
 def _create_model(self, store):
     model = PurchaseWizard._create_model(self, store)
     model.consigned = True
     return model
Exemple #26
0
class TestPurchaseWizard(GUITest):
    def _check_start_step(self, uitest='', identifier="12345"):
        start_step = self.wizard.get_current_step()
        start_step.identifier.update(identifier)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_item_step(self, uitest=''):
        item_step = self.wizard.get_current_step()
        product = self.create_product()
        Storable(product=product, store=self.store)
        item_step.sellable_selected(product.sellable)
        self.click(item_step.add_sellable_button)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_payment_step(self, uitest=''):
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def test_create(self):
        # Allow creating purchases in the past.
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)

        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            self.wizard = PurchaseWizard(self.store)
            purchase_branch = self.create_branch()
            purchase_order = PurchaseOrder(branch=purchase_branch)
            sellable = self.create_sellable()
            purchase_order.add_item(sellable=sellable)
            self.wizard.model.identifier = 12345
            self.wizard.model.open_date = localdate(2010, 1, 3).date()
            self._check_start_step('wizard-purchase-start-step')
            self._check_item_step('wizard-purchase-item-step')
            payment_step = self.wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self._check_payment_step('wizard-purchase-payment-step')

            purchase = self.wizard.model
            models = [purchase]
            models.extend(purchase.get_items())
            models.extend(purchase.payments)
            models.append(purchase.group)

            self.check_wizard(self.wizard,
                              'wizard-purchase-finish-step',
                              models=models)

            self.click(self.wizard.next_button)

    def test_create_without_active_supplier(self):
        # Inactivating all the suppliers, so they wont show on PurchaseWizard
        suppliers = self.store.find(Supplier)
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_INACTIVE

        wizard = PurchaseWizard(self.store)
        step = wizard.get_current_step()
        self.assertEqual(step.edit_supplier.get_sensitive(), False)
        step.supplier.set_text('Invalid supplier')
        self.assertEqual(step.edit_supplier.get_sensitive(), False)

        # Activating the suppliers back
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_ACTIVE

    def test_edit_purchase_without_open_date(self):
        purchase_order = self.create_purchase_order()
        self.create_purchase_order_item(purchase_order)
        purchase_order.status = PurchaseOrder.ORDER_PENDING
        self.wizard = PurchaseWizard(self.store, purchase_order)
        start_step = self.wizard.get_current_step()
        start_step.open_date.update(None)
        self.assertEqual(start_step.open_date.mandatory, True)
        self.assertNotSensitive(self.wizard, ['next_button'])

    def test_create_and_receive(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            self.wizard = PurchaseWizard(self.store)
            self.wizard.model.identifier = 12345
            self.wizard.model.open_date = localdate(2010, 1, 3).date()
            self._check_start_step()
            self._check_item_step()
            payment_step = self.wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self._check_payment_step()

            finish_step = self.wizard.get_current_step()
            finish_step.receive_now.set_active(True)
            self.wizard.model.expected_receival_date = localdate(2010, 1,
                                                                 4).date()

            self.wizard.enable_next()
            self.click(self.wizard.next_button)

            receiving_step = self.wizard.get_current_step()
            receiving_step.invoice_slave.identifier.set_text("12345")
            receiving_step.invoice_slave.invoice_number.update(67890)

            self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

            self.click(self.wizard.next_button)

            purchase = self.wizard.model
            models = [purchase]
            models.extend(purchase.get_items())
            models.extend(purchase.payments)
            models.append(purchase.group)

            receive = self.wizard.receiving_model
            models.append(receive)
            models.extend(receive.get_items())
            for item in receive.get_items():
                models.extend(
                    list(item.sellable.product_storable.get_stock_items()))

            self.check_wizard(self.wizard,
                              'wizard-purchase-done-received',
                              models=models)

    def test_no_receive_now_for_batch_items(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            sellable = self.create_sellable()
            self.create_storable(product=sellable.product, is_batch=True)

            wizard = PurchaseWizard(self.store)
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            step.sellable_selected(sellable)
            self.click(step.add_sellable_button)
            self.click(wizard.next_button)

            payment_step = wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            self.assertNotVisible(step, ['receive_now'])

    def test_purchase_package(self):
        package = self.create_product(description=u'Package', is_package=True)
        component = self.create_product(description=u'component')
        self.create_product_component(product=package, component=component)
        wizard = PurchaseWizard(self.store)

        wizard = PurchaseWizard(self.store)
        self.click(wizard.next_button)

        # Item step
        step = wizard.get_current_step()
        step.sellable_selected(package.sellable)
        self.click(step.add_sellable_button)

        klist = step.slave.klist
        klist.select(klist[0])
        self.assertSensitive(step.slave, ['delete_button'])
        selected = klist.get_selected_rows()
        child = klist.get_descendants(selected[0])
        klist.select(child)
        self.assertNotSensitive(step.slave, ['delete_button'])
Exemple #27
0
class TestPurchaseWizard(GUITest):
    def _check_start_step(self, uitest='', identifier="12345"):
        start_step = self.wizard.get_current_step()
        start_step.identifier.update(identifier)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_item_step(self, uitest=''):
        item_step = self.wizard.get_current_step()
        product = self.create_product()
        Storable(product=product, store=self.store)
        item_step.sellable_selected(product.sellable)
        self.click(item_step.add_sellable_button)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_payment_step(self, uitest=''):
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def testCreate(self):
        # Allow creating purchases in the past.
        sysparam(self.store).update_parameter(u"ALLOW_OUTDATED_OPERATIONS",
                                              u"1")

        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = localdate(2010, 1, 3).date()
        self._check_start_step('wizard-purchase-start-step')
        self._check_item_step('wizard-purchase-item-step')
        self._check_payment_step('wizard-purchase-payment-step')

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        self.check_wizard(self.wizard,
                          'wizard-purchase-finish-step',
                          models=models)

        self.click(self.wizard.next_button)

    def testCreateAndReceive(self):
        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = localdate(2010, 1, 3).date()
        self._check_start_step()
        self._check_item_step()
        self._check_payment_step()

        finish_step = self.wizard.get_current_step()
        finish_step.receive_now.set_active(True)
        self.wizard.model.expected_receival_date = localdate(2010, 1, 4).date()

        self.wizard.enable_next()
        self.click(self.wizard.next_button)

        receiving_step = self.wizard.get_current_step()
        receiving_step.invoice_slave.identifier.update("12345")
        receiving_step.invoice_slave.invoice_number.update(67890)

        self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

        self.click(self.wizard.next_button)

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        receive = self.wizard.receiving_model
        models.append(receive)
        models.extend(receive.get_items())
        for item in receive.get_items():
            models.extend(
                list(item.sellable.product_storable.get_stock_items()))

        self.check_wizard(self.wizard,
                          'wizard-purchase-done-received',
                          models=models)
Exemple #28
0
class TestPurchaseWizard(GUITest):
    def _check_start_step(self, uitest='', order_number="12345"):
        start_step = self.wizard.get_current_step()
        start_step.order_number.update("12345")
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_item_step(self, uitest=''):
        item_step = self.wizard.get_current_step()
        product = self.create_product()
        Storable(product=product, store=self.store)
        item_step.sellable_selected(product.sellable)
        self.click(item_step.add_sellable_button)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_payment_step(self, uitest=''):
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def testCreate(self):
        # Allow creating purchases in the past.
        sysparam(self.store).update_parameter(
            u"ALLOW_OUTDATED_OPERATIONS", u"1")

        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = datetime.date(2010, 1, 3)
        self._check_start_step('wizard-purchase-start-step')
        self._check_item_step('wizard-purchase-item-step')
        self._check_payment_step('wizard-purchase-payment-step')

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        self.check_wizard(self.wizard, 'wizard-purchase-finish-step',
                          models=models)

        self.click(self.wizard.next_button)

    def testCreateAndReceive(self):
        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = datetime.date(2010, 1, 3)
        self._check_start_step()
        self._check_item_step()
        self._check_payment_step()

        finish_step = self.wizard.get_current_step()
        finish_step.receive_now.set_active(True)

        self.click(self.wizard.next_button)

        receiving_step = self.wizard.get_current_step()
        receiving_step.invoice_slave.order_number.update("12345")
        receiving_step.invoice_slave.invoice_number.update(67890)

        self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

        self.click(self.wizard.next_button)

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        receive = self.wizard.receiving_model
        models.append(receive)
        models.extend(receive.get_items())
        for item in receive.get_items():
            models.extend(list(item.sellable.product_storable.get_stock_items()))

        self.check_wizard(self.wizard, 'wizard-purchase-done-received',
                          models=models)
class TestPurchaseWizard(GUITest):
    def _check_start_step(self, uitest='', identifier="12345"):
        start_step = self.wizard.get_current_step()
        start_step.identifier.update(identifier)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_item_step(self, uitest=''):
        item_step = self.wizard.get_current_step()
        product = self.create_product()
        Storable(product=product, store=self.store)
        item_step.sellable_selected(product.sellable)
        self.click(item_step.add_sellable_button)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_payment_step(self, uitest=''):
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def test_create(self):
        # Allow creating purchases in the past.
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)

        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            self.wizard = PurchaseWizard(self.store)
            purchase_branch = self.create_branch()
            purchase_order = PurchaseOrder(branch=purchase_branch)
            sellable = self.create_sellable()
            purchase_order.add_item(sellable=sellable)
            self.wizard.model.identifier = 12345
            self.wizard.model.open_date = localdate(2010, 1, 3).date()
            self._check_start_step('wizard-purchase-start-step')
            self._check_item_step('wizard-purchase-item-step')
            payment_step = self.wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self._check_payment_step('wizard-purchase-payment-step')

            purchase = self.wizard.model
            models = [purchase]
            models.extend(purchase.get_items())
            models.extend(purchase.payments)
            models.append(purchase.group)

            self.check_wizard(self.wizard, 'wizard-purchase-finish-step',
                              models=models)

            self.click(self.wizard.next_button)

    def test_create_without_active_supplier(self):
        # Inactivating all the suppliers, so they wont show on PurchaseWizard
        suppliers = self.store.find(Supplier)
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_INACTIVE

        wizard = PurchaseWizard(self.store)
        step = wizard.get_current_step()
        self.assertEqual(step.edit_supplier.get_sensitive(), False)
        step.supplier.set_text('Invalid supplier')
        self.assertEqual(step.edit_supplier.get_sensitive(), False)

        # Activating the suppliers back
        for supplier in suppliers:
            supplier.status = Supplier.STATUS_ACTIVE

    def test_edit_purchase_without_open_date(self):
        purchase_order = self.create_purchase_order()
        self.create_purchase_order_item(purchase_order)
        purchase_order.status = PurchaseOrder.ORDER_PENDING
        self.wizard = PurchaseWizard(self.store, purchase_order)
        start_step = self.wizard.get_current_step()
        start_step.open_date.update(None)
        self.assertEqual(start_step.open_date.mandatory, True)
        self.assertNotSensitive(self.wizard, ['next_button'])

    def test_create_and_receive(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            self.wizard = PurchaseWizard(self.store)
            self.wizard.model.identifier = 12345
            self.wizard.model.open_date = localdate(2010, 1, 3).date()
            self._check_start_step()
            self._check_item_step()
            payment_step = self.wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self._check_payment_step()

            finish_step = self.wizard.get_current_step()
            finish_step.receive_now.set_active(True)
            self.wizard.model.expected_receival_date = localdate(2010, 1, 4).date()

            self.wizard.enable_next()
            self.click(self.wizard.next_button)

            receiving_step = self.wizard.get_current_step()
            receiving_step.invoice_slave.identifier.set_text("12345")
            receiving_step.invoice_slave.invoice_number.update(67890)

            self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

            self.click(self.wizard.next_button)

            purchase = self.wizard.model
            models = [purchase]
            models.extend(purchase.get_items())
            models.extend(purchase.payments)
            models.append(purchase.group)

            receive = self.wizard.receiving_model
            models.append(receive)
            models.append(receive.receiving_invoice)
            models.extend(receive.get_items())
            for item in receive.get_items():
                models.extend(
                    list(item.sellable.product_storable.get_stock_items()))

            self.check_wizard(self.wizard, 'wizard-purchase-done-received',
                              models=models)

    def test_no_receive_now_for_batch_items(self):
        with self.sysparam(MANDATORY_CHECK_NUMBER=True):
            sellable = self.create_sellable()
            self.create_storable(product=sellable.product, is_batch=True)

            wizard = PurchaseWizard(self.store)
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            step.sellable_selected(sellable)
            self.click(step.add_sellable_button)
            self.click(wizard.next_button)

            payment_step = wizard.get_current_step()
            payment_step.slave.bank_first_check_number.set_text('12')
            self.click(wizard.next_button)

            step = wizard.get_current_step()
            self.assertNotVisible(step, ['receive_now'])

    def test_purchase_package(self):
        package = self.create_product(description=u'Package', is_package=True)
        component = self.create_product(description=u'component')
        self.create_product_component(product=package, component=component)
        wizard = PurchaseWizard(self.store)

        wizard = PurchaseWizard(self.store)
        self.click(wizard.next_button)

        # Item step
        step = wizard.get_current_step()
        step.sellable_selected(package.sellable)
        self.click(step.add_sellable_button)

        klist = step.slave.klist
        klist.select(klist[0])
        self.assertSensitive(step.slave, ['delete_button'])
        selected = klist.get_selected_rows()
        child = klist.get_descendants(selected[0])
        klist.select(child)
        self.assertNotSensitive(step.slave, ['delete_button'])
Exemple #30
0
class TestPurchaseWizard(GUITest):
    def _check_start_step(self, uitest='', identifier="12345"):
        start_step = self.wizard.get_current_step()
        start_step.identifier.update(identifier)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_item_step(self, uitest=''):
        item_step = self.wizard.get_current_step()
        product = self.create_product()
        Storable(product=product, store=self.store)
        item_step.sellable_selected(product.sellable)
        self.click(item_step.add_sellable_button)
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def _check_payment_step(self, uitest=''):
        if uitest:
            self.check_wizard(self.wizard, uitest)
        self.click(self.wizard.next_button)

    def test_create(self):
        # Allow creating purchases in the past.
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)

        self.wizard = PurchaseWizard(self.store)
        purchase_branch = self.create_branch()
        purchase_order = PurchaseOrder(branch=purchase_branch)
        sellable = self.create_sellable()
        purchase_order.add_item(sellable=sellable)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = localdate(2010, 1, 3).date()
        self._check_start_step('wizard-purchase-start-step')
        self._check_item_step('wizard-purchase-item-step')
        self._check_payment_step('wizard-purchase-payment-step')

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        self.check_wizard(self.wizard, 'wizard-purchase-finish-step',
                          models=models)

        self.click(self.wizard.next_button)

    def test_create_and_receive(self):
        self.wizard = PurchaseWizard(self.store)
        self.wizard.model.identifier = 12345
        self.wizard.model.open_date = localdate(2010, 1, 3).date()
        self._check_start_step()
        self._check_item_step()
        self._check_payment_step()

        finish_step = self.wizard.get_current_step()
        finish_step.receive_now.set_active(True)
        self.wizard.model.expected_receival_date = localdate(2010, 1, 4).date()

        self.wizard.enable_next()
        self.click(self.wizard.next_button)

        receiving_step = self.wizard.get_current_step()
        receiving_step.invoice_slave.identifier.update("12345")
        receiving_step.invoice_slave.invoice_number.update(67890)

        self.check_wizard(self.wizard, 'wizard-purchase-invoice-step')

        self.click(self.wizard.next_button)

        purchase = self.wizard.model
        models = [purchase]
        models.extend(purchase.get_items())
        models.extend(purchase.payments)
        models.append(purchase.group)

        receive = self.wizard.receiving_model
        models.append(receive)
        models.extend(receive.get_items())
        for item in receive.get_items():
            models.extend(
                list(item.sellable.product_storable.get_stock_items()))

        self.check_wizard(self.wizard, 'wizard-purchase-done-received',
                          models=models)

    def test_no_receive_now_for_batch_items(self):
        sellable = self.create_sellable()
        product = self.create_product()
        storable = self.create_storable(is_batch=True)
        storable.product = product
        sellable.product = product

        wizard = PurchaseWizard(self.store)
        self.click(wizard.next_button)

        step = wizard.get_current_step()
        step.sellable_selected(sellable)
        self.click(step.add_sellable_button)
        self.click(wizard.next_button)

        self.click(wizard.next_button)

        step = wizard.get_current_step()
        self.assertNotVisible(step, ['receive_now'])
Exemple #31
0
 def _create_model(self, store):
     model = PurchaseWizard._create_model(self, store)
     model.consigned = True
     return model