Esempio n. 1
0
    def test_receive_order(self, print_report, yesno):
        yesno.retval = True

        source_branch = Branch.get_active_remote_branches(self.store)[0]
        dest_branch = api.get_current_branch(self.store)

        # Created and sent the order.
        order = self.create_transfer_order(source_branch=source_branch,
                                           dest_branch=dest_branch)
        self.create_transfer_order_item(order=order)
        order.identifier = 28474
        order.open_date = localdatetime(2012, 2, 2)
        order.send()

        dialog = TransferOrderDetailsDialog(self.store, order)
        self.click(dialog.print_button)
        print_report.assert_called_once_with(dialog.report_class, dialog.model)
        self.assertSensitive(dialog, ['receive_button'])
        with mock.patch.object(self.store, 'commit'):
            self.click(dialog.receive_button)

        yesno.assert_called_once_with(u'Receive the order?', gtk.RESPONSE_YES,
                                      u'Receive', u"Don't receive")

        self.assertEquals(order.status, order.STATUS_RECEIVED)
        self.assertEquals(order.cancel_date, None)
Esempio n. 2
0
    def test_cancel_order_nfce_plugin_active(self, get_plugin_manager,
                                             run_dialog):
        dest_branch = Branch.get_active_remote_branches(
            self.store, api.get_current_branch(self.store))[0]
        source_branch = api.get_current_branch(self.store)

        order = self.create_transfer_order(source_branch=source_branch,
                                           dest_branch=dest_branch)
        self.create_transfer_order_item(order=order)
        order.identifier = 28474
        order.open_date = localdatetime(2012, 2, 2)
        order.send(self.current_user)

        dialog = TransferOrderDetailsDialog(self.store, order)
        self.assertSensitive(dialog, ['cancel_button'])
        get_plugin_manager.is_active.return_value = True
        run_dialog.return_value = Note()
        with mock.patch.object(self.store, 'commit'):
            self.click(dialog.cancel_button)
            msg_text = u"This will cancel the transfer. Are you sure?"
            run_dialog.assert_called_once_with(
                NoteEditor,
                dialog,
                order.store,
                model=None,
                message_text=msg_text,
                label_text=u"Reason",
                mandatory=True,
                ok_button_label=u"Cancel transfer",
                cancel_button_label=u"Don't cancel",
                min_length=15)
        self.assertEqual(order.status, TransferOrder.STATUS_CANCELLED)
        self.assertEqual(order.receival_date, None)
Esempio n. 3
0
    def test_show_received(self):
        transfer = self.create_transfer_order()
        self.create_transfer_order_item(order=transfer)

        transfer.send()
        transfer.receive(self.create_employee())
        dialog = TransferOrderDetailsDialog(self.store, transfer)
        self.check_dialog(dialog, 'dialog-cancelled-order-details-show')
Esempio n. 4
0
 def test_dont_cancel_order(self, run_dialog):
     order = self.create_transfer_order()
     self.create_transfer_order_item(order=order)
     order.identifier = 28474
     order.open_date = localdatetime(2012, 2, 2)
     order.send(self.current_user)
     dialog = TransferOrderDetailsDialog(self.store, order)
     self.assertSensitive(dialog, ['cancel_button'])
     run_dialog.return_value = False
     with mock.patch.object(self.store, 'commit'):
         self.click(dialog.cancel_button)
     self.assertEqual(order.status, TransferOrder.STATUS_SENT)
Esempio n. 5
0
    def test_cancel_order_on_dest_branch(self):
        source_branch = Branch.get_active_remote_branches(self.store)[0]
        dest_branch = api.get_current_branch(self.store)

        order = self.create_transfer_order(source_branch=source_branch,
                                           dest_branch=dest_branch)
        self.create_transfer_order_item(order=order)
        order.identifier = 28474
        order.open_date = localdatetime(2012, 2, 2)
        order.send()

        dialog = TransferOrderDetailsDialog(self.store, order)
        # Destination branch should not cancel the transfer
        self.assertFalse(dialog.cancel_button.get_visible())
Esempio n. 6
0
 def test_cancel_order_sefaz_rejected(self, warning, run_dialog):
     order = self.create_transfer_order()
     self.create_transfer_order_item(order=order)
     order.identifier = 28474
     order.open_date = localdatetime(2012, 2, 2)
     order.send(self.current_user)
     dialog = TransferOrderDetailsDialog(self.store, order)
     self.assertSensitive(dialog, ['cancel_button'])
     run_dialog.return_value = Note()
     module = 'stoqlib.domain.events.StockOperationTryFiscalCancelEvent.emit'
     with mock.patch(module) as emit:
         with mock.patch.object(self.store, 'commit'):
             emit.return_value = False
             self.click(dialog.cancel_button)
     self.assertEqual(order.status, TransferOrder.STATUS_SENT)
     warning.assert_called_once_with(
         "The cancellation was not authorized by SEFAZ. You should do a "
         "reverse transfer.")
Esempio n. 7
0
    def test_cancel_order(self, yesno):
        dest_branch = Branch.get_active_remote_branches(self.store)[0]
        source_branch = api.get_current_branch(self.store)

        order = self.create_transfer_order(source_branch=source_branch,
                                           dest_branch=dest_branch)
        self.create_transfer_order_item(order=order)
        order.identifier = 28474
        order.open_date = localdatetime(2012, 2, 2)
        order.send()

        dialog = TransferOrderDetailsDialog(self.store, order)
        self.assertSensitive(dialog, ['cancel_button'])
        yesno.retval = True
        with mock.patch.object(self.store, 'commit'):
            self.click(dialog.cancel_button)
            yesno.assert_called_once_with(u'Cancel the order?',
                                          gtk.RESPONSE_YES, u'Cancel transfer',
                                          u"Don't cancel")
        self.assertEquals(order.status, TransferOrder.STATUS_CANCELLED)
        self.assertEquals(order.receival_date, None)
Esempio n. 8
0
    def test_show(self):
        transfer = self.create_transfer_order()
        self.create_transfer_order_item(order=transfer)

        dialog = TransferOrderDetailsDialog(self.store, transfer)
        self.check_dialog(dialog, 'dialog-transfer-order-details-show')
Esempio n. 9
0
 def test_add_tab(self):
     order = self.create_transfer_order()
     dialog = TransferOrderDetailsDialog(self.store, order)
     dialog.add_tab(_TestSlave(self.store, object()), u'Test Tab')
     self.check_dialog(dialog, 'dialog-transfer-order-add-tab')
 def test_add_tab(self):
     order = self.create_transfer_order()
     dialog = TransferOrderDetailsDialog(self.store, order)
     dialog.add_tab(_TestSlave(self.store, object()), u'Test Tab')
     self.check_dialog(dialog, 'dialog-transfer-order-add-tab')