Пример #1
0
    def test_show(self, localnow):
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)

        localnow.return_value = localdatetime(2013, 2, 1)

        sellable = self.create_sellable(code=u'Code')
        workorder = self.create_workorder(description=u'Test equipment')
        workorder.identifier = 666
        workorder.supplier_order = u"A1234"
        workorder.client = self.create_client()
        workorder.sellable = sellable
        workorder.category = WorkOrderCategory(store=self.store,
                                               name=u'Categoty XXX')
        workorder.defect_reported = u"Defect reported"
        # Create the editor and check initial state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-initial')

        self.assertEqual(editor.supplier_order.read(), u'A1234')
        self.assertSensitive(editor, ['client'])
        self.assertSensitive(editor, ['category', 'category_create'])
        self.assertSensitive(editor, ['supplier_order'])
        workorder.defect_detected = u"Defect detected"
        workorder.estimated_hours = 10
        workorder.estimated_hours = 100
        workorder.estimated_start = localdatetime(2013, 1, 1)
        workorder.estimated_finish = localdatetime(2013, 1, 2)
        workorder.approve(self.current_user)
        _adjust_history_date(workorder)
        # Create another editor to check approved state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-approved')

        workorder.add_sellable(self.create_sellable(description=u"Product A"),
                               price=99,
                               quantity=2)
        workorder.add_sellable(self.create_sellable(description=u"Product B"),
                               price=5,
                               quantity=100)
        workorder.work(self.current_branch, self.current_user)
        _adjust_history_date(workorder)
        # Create another editor to check work in progress state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-in-progress')

        workorder.finish(self.current_branch, self.current_user)
        _adjust_history_date(workorder)
        # Create another editor to check finished state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-finished')

        for item in workorder.order_items:
            item.reserve(self.current_user, item.quantity)
        workorder.close(self.current_branch, self.current_user)
        _adjust_history_date(workorder)
        # Create another editor to check closed state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-closed')
Пример #2
0
    def test_show(self, localnow):
        localnow.return_value = localdatetime(2013, 2, 1)

        workorder = self.create_workorder(equipment=u'Test equipment')
        workorder.identifier = 666
        workorder.client = self.create_client()
        workorder.category = WorkOrderCategory(store=self.store,
                                               name=u'Categoty XXX')
        workorder.defect_reported = u"Defect reported"
        # Create the editor and check initial state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-initial')

        workorder.defect_detected = u"Defect detected"
        workorder.estimated_hours = 10
        workorder.estimated_hours = 100
        workorder.estimated_start = localdatetime(2013, 1, 1)
        workorder.estimated_finish = localdatetime(2013, 1, 2)
        workorder.approve()
        _adjust_history_date(workorder)
        # Create another editor to check approved state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-approved')

        workorder.add_sellable(self.create_sellable(description=u"Product A"),
                               price=99,
                               quantity=2)
        workorder.add_sellable(self.create_sellable(description=u"Product B"),
                               price=5,
                               quantity=100)
        workorder.work()
        _adjust_history_date(workorder)
        # Create another editor to check work in progress state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-in-progress')

        workorder.finish()
        _adjust_history_date(workorder)
        # Create another editor to check finished state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-finished')

        workorder.close()
        _adjust_history_date(workorder)
        # Create another editor to check closed state
        editor = WorkOrderEditor(self.store, model=workorder)
        self.check_editor(editor, 'editor-workorder-show-closed')
Пример #3
0
    def test_show_with_sale(self, localnow):
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)

        localnow.return_value = localdatetime(2013, 12, 1)

        # Create a work order with sale
        workorder = self.create_workorder(description=u'Test equipment')
        workorder.identifier = 1234
        workorder.sale = self.create_sale()
        workorder.client = self.create_client()
        # Create the editor
        editor = WorkOrderEditor(self.store, model=workorder)
        self.assertNotSensitive(editor, ['client'])
        self.assertNotSensitive(editor, ['category', 'category_create'])
        self.check_editor(editor, 'editor-workorder-with-sale-show')
Пример #4
0
    def test_work_order_editor(self):
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)

        sale = self.create_sale()
        workorder = self.create_workorder()
        workorder.identifier = 1234
        workorder.open_date = localdate(2012, 1, 1)
        workorder.sale = sale

        editor = WorkOrderEditor(store=self.store, model=workorder)
        self.check_editor(editor, u'editor-work-order-optical-plugin')

        # FIXME: baseditor should probably add an api for getting a list
        #        of buttons
        print_button = editor.main_dialog.action_area.get_children()[0]
        assert print_button.get_label() == Gtk.STOCK_PRINT
        with mock.patch(
                'plugins.optical.opticalui.print_report') as print_report_:
            self.click(print_button)
            print_report_.assert_called_once_with(
                OpticalWorkOrderReceiptReport, [editor.model])
Пример #5
0
    def testCreate(self, localnow):
        localnow.return_value = localdatetime(2013, 1, 1)

        # Create those before initializating the editor so they get prefilled
        category = WorkOrderCategory(store=self.store, name=u'Categoty XXX')
        client = self.create_client()

        editor = WorkOrderEditor(self.store)
        editor.model.identifier = 654
        editor.proxy.update('identifier')
        opening_slave = editor.opening_slave
        execution_slave = editor.execution_slave
        item_slave = execution_slave.sellable_item_slave
        quote_slave = editor.quote_slave
        # Check creation state
        self.assertEqual(editor.model.status, WorkOrder.STATUS_OPENED)
        self.check_editor(editor, 'editor-workorder-create')

        editor.equipment.update(u"Test equipment")
        editor.category.update(category)
        self.assertNotSensitive(editor, ['has_client_approval'])
        editor.client.update(client)
        self.assertSensitive(editor, ['has_client_approval'])
        opening_slave.defect_reported.update(u"Defect reported")
        # Check initial state
        self.assertEqual(editor.model.status, WorkOrder.STATUS_OPENED)
        self.check_editor(editor, 'editor-workorder-create-initial')

        quote_slave.defect_detected.update(u"Defect detected")
        quote_slave.estimated_hours.update(10)
        quote_slave.estimated_hours.update(100)
        quote_slave.estimated_start.update(localdatetime(2013, 1, 1))
        quote_slave.estimated_finish.update(localdatetime(2013, 1, 2))
        self.assertInvalid(quote_slave, ['estimated_start'])
        sysparam(self.store).update_parameter(u"ALLOW_OUTDATED_OPERATIONS",
                                              u"1")
        quote_slave.estimated_start.validate(force=True)
        self.assertValid(quote_slave, ['estimated_start'])
        editor.has_client_approval.set_active(True)
        # Check approved state
        self.assertEqual(editor.model.status, WorkOrder.STATUS_APPROVED)
        self.check_editor(editor, 'editor-workorder-create-approved')

        product_sellable = self.create_product(stock=100).sellable
        product_sellable.barcode = u'9988776655'
        service_sellable = self.create_service().sellable
        service_sellable.barcode = u'5566778899'
        item_slave.barcode.set_text(product_sellable.barcode)
        item_slave.barcode.activate()
        item_slave.cost.update(50)
        item_slave.quantity.update(101)
        self.assertNotSensitive(item_slave, ['add_sellable_button'])
        item_slave.quantity.update(99)
        self.assertSensitive(item_slave, ['add_sellable_button'])
        self.click(item_slave.add_sellable_button)
        item_slave.barcode.set_text(service_sellable.barcode)
        item_slave.barcode.activate()
        item_slave.cost.update(100)
        item_slave.quantity.update(2)
        self.click(item_slave.add_sellable_button)
        # Check work in progress state
        self.assertEqual(editor.model.status,
                         WorkOrder.STATUS_WORK_IN_PROGRESS)
        self.check_editor(editor, 'editor-workorder-create-in-progress')

        self.click(editor.main_dialog.ok_button)
        storable = product_sellable.product_storable
        # This should be 1 since we created it with 100 and used 99 in the order
        self.assertEqual(storable.get_balance_for_branch(editor.model.branch),
                         1)
Пример #6
0
    def test_create(self, localnow):
        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', False)

        localnow.return_value = localdatetime(2013, 1, 1)

        # Create those before initializating the editor so they get prefilled
        category = WorkOrderCategory(store=self.store,
                                     name=u'Categoty XXX')
        client = self.create_client()

        with self.sysparam(DEFECT_DETECTED_TEMPLATE=u"XXX\nYYY"):
            editor = WorkOrderEditor(self.store)
            self.assertEqual(editor.model.defect_detected, u"XXX\nYYY")

        editor.model.identifier = 654
        self.assertEqual(editor.supplier_order.read(), u"")
        editor.supplier_order.update(u"A1234")
        editor.proxy.update('identifier')
        editor.proxy.update('supplier_order')
        self.assertEqual(editor.supplier_order.read(), u"A1234")
        opening_slave = editor.opening_slave
        execution_slave = editor.execution_slave
        item_slave = execution_slave.sellable_item_slave
        quote_slave = editor.quote_slave
        self.assertSensitive(editor, ['client'])
        self.assertSensitive(editor, ['supplier_order'])
        self.assertNotSensitive(editor, ['category_edit'])
        # Check creation state
        self.assertEqual(editor.model.status, WorkOrder.STATUS_OPENED)
        self.check_editor(editor, 'editor-workorder-create')

        editor.description.update(u"Test equipment")
        editor.category.update(category)
        self.assertNotSensitive(editor, ['toggle_status_btn'])
        editor.client_gadget.set_value(client)
        self.assertSensitive(editor, ['toggle_status_btn'])
        opening_slave.defect_reported.update(u"Defect reported")
        # Check initial state
        self.assertEqual(editor.model.status, WorkOrder.STATUS_OPENED)
        self.check_editor(editor, 'editor-workorder-create-initial')

        quote_slave.defect_detected.update(u"Defect detected")
        quote_slave.estimated_hours.update(10)
        quote_slave.estimated_hours.update(100)
        quote_slave.estimated_start.update(localdatetime(2013, 1, 1))
        quote_slave.estimated_finish.update(localdatetime(2013, 1, 2))
        self.assertInvalid(quote_slave, ['estimated_start'])

        sysparam.set_bool(self.store, 'ALLOW_OUTDATED_OPERATIONS', True)
        quote_slave.estimated_start.validate(force=True)
        self.assertValid(quote_slave, ['estimated_start'])
        # Clicking the first time will approve the order (put it on waiting state)
        self.click(editor.toggle_status_btn)
        self.assertEqual(editor.model.status, WorkOrder.STATUS_WORK_WAITING)
        # The second time will start thr work
        self.click(editor.toggle_status_btn)
        self.assertEqual(editor.model.status, WorkOrder.STATUS_WORK_IN_PROGRESS)
        _adjust_history_date(editor.model)
        # FIXME: For some reason, history_slave.update_items is not really
        # updating the list (it calls add_list that should do that) and because
        # of that the items' dates are not updated when they should
        # (update_items will call add_list that should call clear before).
        # Calling clear here fixes the problem, but it should not be necessary.
        # This is probably a kiwi issue
        editor.history_slave.details_list.clear()
        editor.history_slave.update_items()
        self.check_editor(editor, 'editor-workorder-create-approved')

        product_sellable = self.create_product(stock=100).sellable
        product_sellable.barcode = u'9988776655'
        service_sellable = self.create_service().sellable
        service_sellable.barcode = u'5566778899'
        item_slave.barcode.set_text(product_sellable.barcode)
        item_slave.barcode.activate()
        item_slave.cost.update(50)
        item_slave.quantity.update(101)
        self.assertNotSensitive(item_slave, ['add_sellable_button'])
        item_slave.quantity.update(99)
        self.assertSensitive(item_slave, ['add_sellable_button'])
        self.click(item_slave.add_sellable_button)
        item_slave.barcode.set_text(service_sellable.barcode)
        item_slave.barcode.activate()
        item_slave.cost.update(100)
        item_slave.quantity.update(2)
        self.click(item_slave.add_sellable_button)
        # Check work in progress state
        self.check_editor(editor, 'editor-workorder-create-in-progress')

        self.click(editor.main_dialog.ok_button)
        storable = product_sellable.product_storable
        # This should be 1 since we created it with 100 and used 99 in the order
        self.assertEqual(
            storable.get_balance_for_branch(editor.model.branch), 1)