Esempio n. 1
0
    def setUpClass(cls):

        # In process so that the server is bypassed (or else
        # I have to run a server in parallel)
        cls.remote_documents_service = JsonCallWrapper(documents_service,JsonCallWrapper.DIRECT_MODE)
        cls.remote_indicators_service = IndicatorsService()

        configuration.set('Programs','pdf_viewer',None)

        mainlog.debug("TestBase.setUpClass : init database")


        from koi.dao import dao, DAO
        init_test_database()

        cls.open_locks_on_startup = cls._count_open_locks()

        mainlog.debug("TestBase.setUpClass")
        cls.dao = DAO()
        cls.dao.set_session(session)
        dao.set_session(session)

        cls._operation_definition_dao = cls.dao.operation_definition_dao
        cls.dao_employee = cls.dao.employee_dao
        cls.tar_dao = cls.dao.task_action_report_dao
        cls.task_dao = cls.dao.task_dao
        cls.timetrack_dao = cls.dao.timetrack_dao
        cls.delivery_slip_dao = cls.dao.delivery_slip_part_dao
        cls.order_dao = cls.dao.order_dao
        cls.day_time_synthesis_dao = cls.dao.day_time_synthesis_dao
        cls.month_time_synthesis_dao = cls.dao.month_time_synthesis_dao
        cls._production_file_dao = cls.dao.production_file_dao
        cls.employee_dao = cls.dao.employee_dao
        cls._order_dao = cls.dao.order_dao
        cls._order_part_dao = cls.dao.order_part_dao
        cls._operation_dao = cls.dao.operation_dao
        cls._customer_dao = cls.dao.customer_dao

        cls.customer = cls._customer_dao.make(u"Si"+ chr(233) + u"mens")
        cls.customer.address1 = u"Square Niklaus Wirth"+ chr(233)
        cls.customer.country = u"Pakistan"+ chr(233)
        cls.customer.phone = u"+494 0412 32 32 6654"
        cls.customer.email = u"*****@*****.**"

        cls._customer_dao.save(cls.customer)

        session().flush()

        cls.customer_id = cls.customer.customer_id

        cls.opdef = cls._operation_definition_dao.make()
        cls.opdef.short_id = "Unbi"
        cls.opdef.description = u"Unbi" + chr(233)
        cls.opdef.imputable = True
        cls.opdef.on_order = False
        cls.opdef.on_operation = False

        period = OperationDefinitionPeriod()
        period.start_date, period.end_date = date(2010,1,1), None
        cls.opdef.periods.append(period)

        cls._operation_definition_dao.save(cls.opdef)

        cls.nonbillable_op = cls.opdef
        cls.nonbillable_op_id = cls.opdef.operation_definition_id


        cls.opdef2 = cls._operation_definition_dao.make()
        cls.opdef2.short_id = "Unbi2"
        cls.opdef2.description = u"Unbi2"+ chr(233)
        cls.opdef2.imputable = True
        cls.opdef2.on_order = False
        cls.opdef2.on_operation = False

        period = OperationDefinitionPeriod()
        period.start_date, period.end_date = date(2010,1,1), None
        cls.opdef2.periods.append(period)

        cls._operation_definition_dao.save(cls.opdef2)


        cls.not_imputable_opdef_on_order = cls._operation_definition_dao.make()
        cls.not_imputable_opdef_on_order.short_id = "OnOrder"
        cls.not_imputable_opdef_on_order.description = u"OnOrder (not imputable)" + chr(233)
        cls.not_imputable_opdef_on_order.imputable = False
        cls.not_imputable_opdef_on_order.on_order = True
        cls.not_imputable_opdef_on_order.on_operation = False

        period = OperationDefinitionPeriod()
        period.start_date, period.end_date = date(2010,1,1), None
        cls.not_imputable_opdef_on_order.periods.append(period)

        cls._operation_definition_dao.save(cls.not_imputable_opdef_on_order)

        cls.not_imputable_opdef_on_operation = cls._operation_definition_dao.make()
        cls.not_imputable_opdef_on_operation.short_id = "MA"
        cls.not_imputable_opdef_on_operation.description = u"OnOperation (not imputable)" + chr(233)
        cls.not_imputable_opdef_on_operation.imputable = False
        cls.not_imputable_opdef_on_operation.on_order = False
        cls.not_imputable_opdef_on_operation.on_operation = True
        period = OperationDefinitionPeriod()
        period.start_date = date(2010,1,1)
        period.cost = 63.3 # BUG Cost makes no sense for non imputable task or does it ?
        cls.not_imputable_opdef_on_operation.periods.append(period)

        cls._operation_definition_dao.save(cls.not_imputable_opdef_on_operation)

        session().flush()

        # A regular operation

        mainlog.debug("Creating a regular operation definition")
        cls.opdef_op = cls._operation_definition_dao.make()
        cls.opdef_op.short_id = "TO"
        cls.opdef_op.description = u"Tournag" + chr(233)
        cls.opdef_op.imputable = True
        cls.opdef_op.on_order = False
        cls.opdef_op.on_operation = True

        period = OperationDefinitionPeriod()
        period.start_date = date(2010,1,1)
        period.cost = 63.3

        cls.opdef_op.periods.append(period)
        cls._operation_definition_dao.save( cls.opdef_op)

        # cls.dao.operation_definition_dao.add_period(period, cls.opdef_op)
        session().flush()
        mainlog.debug("Creating a regular operation definition => id is {}".format(cls.opdef_op.operation_definition_id))

        cls.opdef_order = cls._operation_definition_dao.make()
        cls.opdef_order.short_id = "ZO"
        cls.opdef_order.description = u"Analyse order " + chr(233)
        cls.opdef_order.imputable = True
        cls.opdef_order.on_order = True
        cls.opdef_order.on_operation = False

        period = OperationDefinitionPeriod()
        period.start_date, period.end_date = date(2010,1,1), None
        cls.opdef_order.periods.append(period)

        cls._operation_definition_dao.save(cls.opdef_order)

        cls.employee = cls.dao_employee.create(u"Don d. Knuth"+ chr(233))
        cls.employee.login = "******"

        h = hashlib.md5()
        h.update('kk'.encode('utf-8'))

        cls.employee.password = h.hexdigest()
        cls.employee_id = cls.employee.employee_id

        user_session.open(cls.employee)

        cls.reporter = cls.dao_employee.create(u"George Orwell")
        cls.reporter.login = "******"
        cls.reporter.password = h.hexdigest()
        cls.reporter_id = cls.reporter.employee_id

        # It's already in the basic database
        # fq = FilterQuery()
        # fq.family = "order_parts_overview"
        # fq.query = "CreationDate > 1/1/2016"
        # fq.owner_id = cls.employee_id
        # fq.name = "production"
        # f = cls.dao.filters_dao.save(fq)

        session().commit()

        mainlog.debug("***************************************************** CLASS INIT completed")
        cls.timer = QTimer()
        cls.timer_connected = False
        cls.dialog_to_click = []
Esempio n. 2
0
            #     event.ignore()
            return super(MyLineEdit, self).keyPressEvent(event)
        else:
            return super(MyLineEdit, self).keyPressEvent(event)


# class MyLineEdit(QWidget):
#     def __init__(self):
#         super(MyLineEdit,self).__init()
#         l = QHBoxLayout()
#         l.addWidget(QLineEdit())
#         self.setLayout(l)

if __name__ == "__main__":
    from koi.junkyard.services import services
    employee = services.employees.any()
    user_session.open(employee)

    app = QApplication(sys.argv)

    window = QMainWindow()
    window.setMinimumSize(1024, 768)
    widget = OrderOverviewWidget(window, None, None)
    widget.refresh_action()
    window.setCentralWidget(widget)
    window.show()

    # presence.refresh_action()

    app.exec_()
Esempio n. 3
0
File: python.py Progetto: wiz21b/koi
def all_systems_go():
    global user_session,configuration,window, args

    mainlog.debug("all_systems_go() : init dao")
    dao.set_session(session())
    mainlog.debug("all_systems_go() : call back")
    dao.set_callback_operational_error(database_operational_error)

    mainlog.debug("all_systems_go() : building mainwindow")
    window = MainWindow(dao)
    window.setMinimumSize(1024,768)
    splash.finish(window)


    mainlog.debug("all_systems_go() : login dialog")
    if not user_session.is_active(): # the configuration may have forced a user

        # Special case for demo

        from koi.datalayer.employee_mapping import Employee
        if 'koi-mes.net' in configuration.get("DownloadSite", "base_url") or args.demo:
            user_session.open(
                dao.employee_dao.authenticate(
                    "roba", Employee.hash_password("roba")))
            d = AboutDemoDialog(None)
            d.exec_()
        else:
            d = LoginDialog(window, user_session)
            d.exec_()

        # splash.repaint()

    # zzz = QWidget()
    # splash.finish(zzz)
    # splash.show()
    # splash.update()
    # from PySide.QtGui import QSound
    # snd = QSound(os.path.join(resource_dir,'logo_sound.wav'))
    # splash.timer.start(25)
    # splash.alpha = 255
    # snd.play()

    if user_session.is_active():
        # d = LoginDialog(window, user_session)
        # d.exec_()

        window.build()
        w = StatusWidget2(window, user_session.name)
        window.statusBar().addWidget(w,100000)
        window.statusBar().setSizeGripEnabled(False)

        _koi_base.set_main_window(window)
        window.module = IndicatorsModule()
        window.module.wire( _koi_base)

        # window.showMaximized() # If I maximize what happens to multiscreens ?
        window.showMaximized()
        # splash = SplashScreen(pixmap)

        if args.screenshots:
            make_screenshot()

        app.exec_()
    else:
        # User was no authorized
        showWarningBox(_("Not authorized"),_("You are not authorized to use this program. Please check with your system administrator."))

    dao.close()