Ejemplo n.º 1
0
    def __init__(self, parent=0, *args, **kwargs):
        super(InventoryViewWidget, self).__init__(parent=parent,
                                                  *args,
                                                  **kwargs)

        self.parentWidget().setWindowTitle(Config.APP_NAME +
                                           u"     INVENTAIRE")

        self.parent = parent

        self.title = u"Inventaire"

        self.on_date = FormatDate(QDate(date.today().year, 1, 1))
        self.end_date = FormatDate(QDate.currentDate())
        self.button = Button(u"Ok")
        self.button.clicked.connect(self.rapport_filter)
        self.btt_export = BttExportXLSX(u"Exporter")
        self.btt_export.clicked.connect(self.export_xls)

        self.invent_table = InventaireTableWidget(parent=self)
        # Grid
        gridbox = QGridLayout()
        gridbox.addWidget(FormLabel(u"Date debut"), 0, 1)
        gridbox.addWidget(self.on_date, 0, 2)
        gridbox.addWidget(FormLabel(u"Date fin"), 1, 1)
        gridbox.addWidget(self.end_date, 1, 2)
        gridbox.addWidget(self.button, 1, 3)
        gridbox.addWidget(self.btt_export, 1, 6)
        gridbox.setColumnStretch(4, 5)
        vbox = QVBoxLayout()
        vbox.addWidget(FPageTitle(self.title))
        vbox.addLayout(gridbox)
        vbox.addWidget(self.invent_table)
        self.setLayout(vbox)
        self.refresh()
Ejemplo n.º 2
0
    def __init__(self, parent=0, *args, **kwargs):
        super(PeriodByViewWidget, self).__init__(parent=parent,
                                                 *args,
                                                 **kwargs)
        self.parent = parent
        self.title = FPageTitle(_(u"Periodic report"))

        self.on_date = FormatDate(QDate(date.today().year, 1, 1))
        self.end_date = FormatDate(QDate.currentDate())
        self.Button = Button(u"OK")
        self.Button.clicked.connect(self.rapport_filter)
        self.current_period = FLabel(
            self.format_period(self.on_date.text(), self.end_date.text()))
        vbox = QVBoxLayout()
        # Grid
        gridbox = QGridLayout()
        gridbox.addWidget(FormLabel(u"Date debut"), 0, 0)
        gridbox.addWidget(self.on_date, 0, 1)
        gridbox.addWidget(FormLabel(u"Date fin"), 1, 0)
        gridbox.addWidget(self.end_date, 1, 1)
        gridbox.addWidget(self.Button, 1, 2)
        gridbox.setColumnStretch(3, 1)

        gridbox.addWidget(self.current_period, 1, 4)

        self.table = By_periodTableWidget(parent=self)

        vbox.addWidget(self.title)
        vbox.addLayout(gridbox)
        vbox.addWidget(self.table)
        self.setLayout(vbox)
Ejemplo n.º 3
0
    def __init__(self, parent=0, *args, **kwargs):

        super(PaymentViewWidget, self).__init__(parent=parent, *args, **kwargs)
        FPeriodHolder.__init__(self, *args, **kwargs)

        self.parentWidget().setWindowTitle(Config.APP_NAME + u"   Movements")
        self.parent = parent

        self.title = u"Movements"

        self.on_date = FormatDate(
            QDate(date.today().year,
                  date.today().month, 1))
        self.end_date = FormatDate(QDate.currentDate())
        self.now = datetime.now().strftime("%x")
        self.soldeField = FormLabel("0")
        self.label_balance = FormLabel(u"Solde au {} ".format(self.now))
        balanceBox = QGridLayout()
        balanceBox.addWidget(self.label_balance, 0, 2)
        balanceBox.addWidget(self.soldeField, 0, 3)
        balanceBox.setColumnStretch(0, 1)

        self.table = RapportTableWidget(parent=self)
        self.button = Button(u"Ok")
        self.button.clicked.connect(self.table.refresh_)

        self.btt_export = BttExportXLSX(u"Exporter")
        self.btt_export.clicked.connect(self.export_xls)
        self.add_btt = Button("Créditer")
        self.add_btt.setIcon(
            QIcon(u"{img_media}{img}".format(img_media=Config.img_media,
                                             img="in.png")))
        self.add_btt.clicked.connect(self.add_payment)
        self.sub_btt = Button("Débiter")
        self.sub_btt.setIcon(
            QIcon(u"{img_media}{img}".format(img_media=Config.img_media,
                                             img="out.png")))
        self.sub_btt.clicked.connect(self.sub_payment)

        editbox = QGridLayout()
        editbox.addWidget(FormLabel(u"Date debut"), 0, 1)
        editbox.addWidget(self.on_date, 0, 2)
        editbox.addWidget(FormLabel(u"Date fin"), 1, 1)
        editbox.addWidget(self.end_date, 1, 2)
        editbox.addWidget(self.button, 1, 3)

        editbox.addWidget(self.sub_btt, 1, 5)
        editbox.addWidget(self.add_btt, 1, 6)
        editbox.addWidget(self.btt_export, 1, 7)
        editbox.setColumnStretch(4, 2)
        vbox = QVBoxLayout()
        vbox.addWidget(FPageTitle(self.title))
        vbox.addLayout(editbox)
        vbox.addWidget(self.table)
        vbox.addLayout(balanceBox)
        self.setLayout(vbox)
Ejemplo n.º 4
0
    def __init__(self, parent=0, *args, **kwargs):

        super(ProvidersViewWidget, self).__init__(parent=parent,
                                                  *args,
                                                  **kwargs)

        self.parent = parent

        self.title = u"Movements"

        self.on_date = FormatDate(QDate(date.today().year, 1, 1))
        self.end_date = FormatDate(QDate.currentDate())
        # self.now = datetime.now().strftime("%x")
        self.soldeField = FormLabel("{}".format(device_amount(0)))
        balanceBox = QGridLayout()
        balanceBox.addWidget(self.soldeField, 0, 3)
        balanceBox.setColumnStretch(0, 1)

        self.string_list = [""] + [
            "{},{}".format(clt.name, clt.phone)
            for clt in ProviderOrClient.select().where(
                ProviderOrClient.type_ == ProviderOrClient.CLT).order_by(
                    ProviderOrClient.name.desc())
        ]

        self.name_client_field = ExtendedComboBox()
        self.name_client_field.addItems(self.string_list)
        self.name_client_field.setMaximumSize(
            200,
            self.name_client_field.maximumSize().height())
        self.name_client_field.setToolTip("Nom, numero du client")

        self.table = RapportTableWidget(parent=self)
        self.button = Button(u"Ok")
        self.button.clicked.connect(self.refresh_prov_clt)

        self.btt_export = BttExportXLSX(u"Exporter")
        self.btt_export.clicked.connect(self.export_xls)

        editbox = QGridLayout()
        editbox.addWidget(FormLabel(u"Date debut"), 0, 1)
        editbox.addWidget(self.on_date, 0, 2)
        editbox.addWidget(FormLabel(u"Date fin"), 1, 1)
        editbox.addWidget(self.end_date, 1, 2)
        editbox.addWidget(self.name_client_field, 0, 3)
        editbox.addWidget(self.button, 1, 3)

        editbox.addWidget(self.btt_export, 1, 7)
        editbox.setColumnStretch(4, 2)
        vbox = QVBoxLayout()
        vbox.addWidget(FPageTitle(self.title))
        vbox.addLayout(editbox)
        vbox.addWidget(self.table)
        vbox.addLayout(balanceBox)
        self.setLayout(vbox)
Ejemplo n.º 5
0
    def __init__(self, table_p, parent, type_=None, payment=None, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        self.type_ = type_
        self.payment = payment
        self.parent = parent
        self.table_p = table_p

        if self.payment:
            self.new = False
            self.type_ = payment.type_
            self.payment_date_field = FormatDate(self.payment.date)
            self.payment_date_field.setEnabled(False)
            self.title = u"Modification de {} {}".format(self.payment.type_,
                                                         self.payment.libelle)
            self.succes_msg = u"{} a été bien mise à jour".format(
                self.payment.type_)

            if self.type_ == Payment.CREDIT:
                amount = payment.credit
            elif self.type_ == Payment.DEBIT:
                amount = payment.debit
        else:
            self.new = True
            amount = ""
            self.payment_date_field = FormatDate(QDate.currentDate())
            self.succes_msg = u"Client a été bien enregistré"
            self.title = u"Création d'un nouvel client"
            self.payment = Payment()
        self.setWindowTitle(self.title)

        self.amount_field = IntLineEdit(unicode(amount))
        self.libelle_field = QTextEdit(self.payment.libelle)

        vbox = QVBoxLayout()

        formbox = QFormLayout()
        formbox.addRow(FormLabel(u"Date : *"), self.payment_date_field)
        formbox.addRow(FormLabel(u"Libelle :"), self.libelle_field)
        formbox.addRow(FormLabel(u"Montant : *"), self.amount_field)

        butt = ButtonSave(u"Enregistrer")
        butt.clicked.connect(self.save_edit)
        formbox.addRow("", butt)

        vbox.addLayout(formbox)
        self.setLayout(vbox)
Ejemplo n.º 6
0
    def office_group_box(self):
        self.organGroupBoxBtt = QGroupBox(
            self.tr("Configuration des localités"))

        self.office_box = QComboBox()
        self.office_box.currentIndexChanged.connect(self.change_select_office)

        self.office_list = get_offices()
        self.region_box = QComboBox()
        self.region_label = FLabel()
        self.cercle_label = FLabel()
        self.phone_field = IntLineEdit()
        self.phone_field.setInputMask('## ## ## ##')
        self.bp = LineEdit()
        self.adress_org = QTextEdit()
        self.email_org = LineEdit()

        for index, value in enumerate(self.office_list):
            self.office_box.addItem("{}".format(office_name(value)), value)

        formbox = QFormLayout()
        formbox.addRow(FormLabel(u"Nom service :"), self.office_box)
        formbox.addRow(FormLabel(u"Région"), self.region_label)
        formbox.addRow(FormLabel(u"Cercle"), self.cercle_label)
        formbox.addRow(FormLabel(u"Tel :"), self.phone_field)
        formbox.addRow(FormLabel(u"B.P :"), self.bp)
        formbox.addRow(FormLabel(u"E-mail :"), self.email_org)
        formbox.addRow(FormLabel(u"Adresse complete :"), self.adress_org)
        butt = Button_save(u"Enregistrer")
        butt.clicked.connect(self.save_edit)
        formbox.addRow("", butt)

        self.organGroupBoxBtt.setLayout(formbox)
Ejemplo n.º 7
0
    def __init__(self, parent=0, *args, **kwargs):
        super(BuyViewWidget, self).__init__(parent=parent, *args, **kwargs)
        self.parentWidget().setWindowTitle(Config.APP_NAME +
                                           u"    Arrivage d'article")
        self.parent = parent

        vbox = QVBoxLayout()
        hbox = QHBoxLayout()
        editbox = QGridLayout()

        self.date = FormatDate(QDate.currentDate())
        self.name_client = LineEdit()
        self.search_field = LineEdit()
        self.search_field.setPlaceholderText("Rechercher un article")
        self.search_field.setMaximumHeight(40)
        self.search_field.textChanged.connect(self.finder)
        # self.search_field.setFixedWidth(200)

        self.add_prod = Button(u"+ &Article")
        self.add_prod.clicked.connect(self.add_product)
        self.add_prod.setFixedWidth(80)
        # self.add_prod.setFixedHeight(20)
        self.add_prod.setStyleSheet("Text-align:botton")
        self.add_prod.setToolTip("Ajouter un nouvel article")

        self.table_buy = BuyTableWidget(parent=self)
        self.table_resultat = ResultatTableWidget(parent=self)
        self.table_info = InfoTableWidget(parent=self)

        editbox.addWidget(self.add_prod, 0, 1)
        editbox.addWidget(FormLabel(u"Date d'achat:"), 0, 4)
        editbox.addWidget(self.date, 0, 5)

        editbox.setColumnStretch(3, 3)
        splitter = QSplitter(Qt.Horizontal)

        splitter_left = QSplitter(Qt.Vertical)
        splitter_down = QSplitter(Qt.Vertical)
        splitter_left.addWidget(self.search_field)
        splitter_left.addWidget(self.table_resultat)
        splitter_down.resize(35, 20)
        splitter_down.addWidget(self.table_info)

        splitter_rigth = QSplitter(Qt.Vertical)
        splitter_rigth.addWidget(self.table_buy)
        splitter_rigth.resize(800, 900)

        splitter_left.addWidget(splitter_down)
        splitter.addWidget(splitter_left)
        splitter.addWidget(splitter_rigth)

        hbox.addWidget(splitter)
        vbox.addLayout(editbox)
        vbox.addLayout(hbox)
        self.setLayout(vbox)
Ejemplo n.º 8
0
    def __init__(self, table_p, parent, provid_clt=None, type_=None, refund=None, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        self.type_ = type_
        self.refund = refund
        self.parent = parent
        self.table_p = table_p
        self.provid_clt = provid_clt
        self.new = True
        if self.refund:
            self.new = False
            self.last_r = self.refund
            self.type_ = refund.type_
            self.refund_date_field = FormatDate(self.refund.date)
            self.refund_date_field.setEnabled(False)
            self.title = u"Modification de {} {}".format(self.refund.type_,
                                                         self.refund.invoice.client)
            self.succes_msg = u"{} a été bien mise à jour".format(
                self.refund.type_)
            self.amount = refund.amount
            self.provid_clt = refund.provider_client
        else:
            self.refund_date_field = FormatDate(QDate.currentDate())
            self.succes_msg = u"Client a été bien enregistré"
            self.title = u"Création d'un nouvel client"
            self.amount = ""
            self.refund = Refund()
            self.last_r = Refund.select().where(
                Refund.provider_client == provid_clt).order_by(Refund.date.desc()).get()

        self.setWindowTitle(self.title)
        self.amount_field = IntLineEdit(unicode(self.amount))

        vbox = QVBoxLayout()
        self.last_remaining = self.last_r.refund_remaing()
        # try:
        #     self.last_r.refund_remaing()
        # self.remaining = self.last_r.remaining
        # except Exception as e:
        #     self
        #     print("last_r except ", e)
        #     self.last_r = None
        # self.close()

        formbox = QFormLayout()
        formbox.addRow(FormLabel("Client :"),
                       FormLabel(self.provid_clt.name))
        formbox.addRow(FormLabel("Dette restante :"),
                       FormLabel(str(formatted_number(self.last_remaining))))
        formbox.addRow(FormLabel(u"Date : *"), self.refund_date_field)
        formbox.addRow(FormLabel(u"Montant : *"), self.amount_field)

        butt = ButtonSave(u"Enregistrer")
        butt.clicked.connect(self.save_edit)
        formbox.addRow("", butt)
        # formbox.addRow("", "Le client {} n'est pas endetté")

        vbox.addLayout(formbox)
        self.setLayout(vbox)
Ejemplo n.º 9
0
    def __init__(self, hibernate=False):
        QDialog.__init__(self)
        self.setWindowTitle(self.set_window_title(self.title_page))
        self.hibernate = hibernate

        self.setWindowFlags(Qt.FramelessWindowHint)
        self.title = FormLabel(
            "<h4>{app_name}</h4><stromg>Ver: {version}</stromg>".format(
                app_name=Config.APP_NAME, version=Config.APP_VERSION))
        self.title.setStyleSheet(
            """ background: url({})#DAF7A6;
                border-radius: 14px 14px 8px 8px; border: 10px double #128a76 ;
                width: 100%; height: auto; padding: 1em;
                font: 8pt 'URW Bookman L';""".format(
                Config.APP_LOGO))
        vbox = QHBoxLayout()

        self.loginUserGroupBox()
        vbox.addWidget(self.title)
        vbox.addWidget(self.topLeftGroupBox)
        # set focus to username field
        self.setFocusProxy(self.password_field)
        self.setLayout(vbox)
Ejemplo n.º 10
0
    def __init__(self, parent=0, *args, **kwargs):
        super(OrderViewWidget, self).__init__(parent=parent, *args, **kwargs)

        self.order_table = OrederTableWidget(parent=self)
        self.parentWidget().setWindowTitle("{} {}".format(
            Config.APP_NAME, "COMMANDE"))

        self.title = FPageTitle(u"Faire une Commande")

        self.com_date = FormatDate(QDate.currentDate())
        vbox = QVBoxLayout()

        self.export_xls_btt = BttExportXLSX(u"Exporter")
        self.connect(self.export_xls_btt, SIGNAL('clicked()'),
                     self.export_xls_order)

        # self.save_order_btt = ButtonSave(u"enregistre")
        # self.connect(self.save_order_btt, SIGNAL('clicked()'),
        #              self.save_order)

        self.restor_order_btt = DeletedBtt(u"vider")
        self.connect(self.restor_order_btt, SIGNAL('clicked()'),
                     self.remove_save)

        # Grid
        gridbox = QGridLayout()
        gridbox.addWidget(FormLabel(u"Date"), 0, 0)
        gridbox.addWidget(self.com_date, 0, 1)
        gridbox.setColumnStretch(1, 5)
        gridbox.addWidget(self.restor_order_btt, 2, 2)
        # gridbox.addWidget(self.save_order_btt, 2, 3)
        gridbox.addWidget(self.export_xls_btt, 2, 4)
        vbox.addWidget(self.title)
        vbox.addLayout(gridbox)
        vbox.addWidget(self.order_table)
        self.setLayout(vbox)
Ejemplo n.º 11
0
    def __init__(self,
                 table_p,
                 parent,
                 scoop=None,
                 member=None,
                 *args,
                 **kwargs):
        FWidget.__init__(self, parent, *args, **kwargs)

        self.table_p = table_p
        self.member = member
        self.scoop = scoop
        self.parent = parent
        full_name = ""
        self.ddn_field = FormatDate(QDate(QDate.currentDate()))

        addres = ""
        nationality = ""
        phone = ""
        if self.member:
            self.new = False
            full_name = self.member.full_name
            mddn = self.member.ddn
            if mddn:
                day, month, year = mddn.split("/")
                ddn = datetime.strptime(mddn, '%d/%m/%Y')
                self.ddn_field.setDate(QDate(ddn))
            addres = self.member.addres
            nationality = self.member.nationality
            phone = str(self.member.phone or "")

            self.title = u"Modification de {}".format(self.member)
            self.succes_msg = u"{} a été bien mise à jour".format(self.member)
        else:
            self.new = True
            self.succes_msg = u"Client a été bien enregistré"
            self.title = u"Ajout nouveau membre"
            self.member = CooperativeMember()
        self.setWindowTitle(self.title)

        vbox = QVBoxLayout()
        # vbox.addWidget(FPageTitle(u"Utilisateur: %s " % self.member.name))

        self.full_name_field = LineEdit(full_name)
        self.sex_list = CooperativeMember.SEX.items()
        # Combobox widget
        self.sex_box = QComboBox()

        for index, value in enumerate(self.sex_list):
            # form = self.sex_list[index]
            self.sex_box.addItem("{}".format(value[1].upper()), value[0])
            if self.member.sex == value[0]:
                self.sex_box.setCurrentIndex(index)
        # print("DE", ddn)
        # self.ddn_field.setDate(ddn)
        # self.ddn_field = QDateEdit(QDate(ddn))
        self.addres_field = QTextEdit(addres)
        self.nationality_field = LineEdit(nationality)
        self.phone_field = IntLineEdit(phone)
        self.phone_field.setInputMask("## ## ## ##")
        self.poste_list = get_postes()
        self.poste_box = QComboBox()
        for index, value in enumerate(self.poste_list):
            self.poste_box.addItem(
                "{}".format(self.poste_list.get(value).upper()), value)
            if self.member.poste == value:
                print(value)
                self.poste_box.setCurrentIndex(index)

        formbox = QFormLayout()
        formbox.addRow(FormLabel(u"Nom complet : *"), self.full_name_field)
        formbox.addRow(FormLabel(u"Sexe *:"), self.sex_box)
        formbox.addRow(FormLabel(u"Date de naissance *:"), self.ddn_field)
        formbox.addRow(FormLabel(u"Poste occupé *:"), self.poste_box)
        formbox.addRow(FormLabel(u"Nationalité *:"), self.nationality_field)
        formbox.addRow(FormLabel(u"Téléphone :"), self.phone_field)
        formbox.addRow(FormLabel(u"Adresse :"), self.addres_field)

        butt = Button(u"Enregistrer")
        butt.clicked.connect(self.save_edit)
        formbox.addRow("", butt)

        vbox.addLayout(formbox)
        self.setLayout(vbox)
Ejemplo n.º 12
0
    def __init__(self, table_p, report, parent, *args, **kwargs):
        QDialog.__init__(self, parent, *args, **kwargs)

        self.setWindowTitle(u"Modification")
        self.table_p = table_p
        self.rpt = report
        self.parent = parent

        self.out_op = True
        if self.rpt.type_ == Report.E:
            self.out_op = False

        self.selling_price_field = IntLineEdit(unicode(self.rpt.selling_price))
        self.cost_buying_field = IntLineEdit(unicode(self.rpt.cost_buying))
        self.qty_field = IntLineEdit(unicode(self.rpt.qty))

        self.date_field = FormatDate(QDate(self.rpt.date))
        self.date_field.setEnabled(False)

        butt = Button(u"Mise à jour")
        butt.clicked.connect(self.edit_report)
        cancel_but = Button(u"Annuler")
        cancel_but.clicked.connect(self.cancel)

        # Combobox widget
        i = 0
        self.liste_type = [Report.E, Report.S]
        self.box_type = QComboBox()
        self.box_type.setEnabled(False)
        for index in xrange(0, len(self.liste_type)):
            ty = self.liste_type[index]
            if ty == self.rpt.type_:
                i = index
            sentence = u"%(ty)s" % {'ty': ty}
            self.box_type.addItem(sentence, ty)
            self.box_type.setCurrentIndex(i)
        # Combobox widget
        # self.liste_store = Store.order_by(desc(Store.id)).all()
        # self.box_mag = QComboBox()
        # for index in xrange(0, len(self.liste_store)):
        #     op = self.liste_store[index]
        #     sentence = u"%(name)s" % {'name': op.name}
        #     self.box_mag.addItem(sentence, QVariant(op.id))
        # Combobox widget

        self.liste_product = Product.all()
        self.box_prod_field = QComboBox()
        self.box_prod_field.setEnabled(False)

        for index in xrange(0, len(self.liste_product)):
            prod = self.liste_product[index]
            if prod.name == self.rpt.product.name:
                i = index
            sentence = u"%(name)s" % {'name': prod.name}
            self.box_prod_field.addItem(sentence, prod.id)
            self.box_prod_field.setCurrentIndex(i)
        vbox = QVBoxLayout()
        formbox = QFormLayout()
        # editbox.addWidget(FormLabel((_(u"Store"))), 0, 1)
        # editbox.addWidget(self.box_mag, 1, 1)
        formbox.addRow(FormLabel(u"Type"), FormLabel(self.rpt.type_))
        formbox.addRow(FormLabel(u"Désignation"), self.box_prod_field)
        formbox.addRow(FormLabel(u"Quantité"), self.qty_field)
        formbox.addRow(FormLabel("Prix d'achat"), self.cost_buying_field)
        formbox.addRow(FormLabel("Prix vente"), self.selling_price_field)
        formbox.addRow(FormLabel(u"Date"), self.date_field)
        formbox.addRow(butt, cancel_but)
        vbox.addLayout(formbox)
        self.setLayout(vbox)
Ejemplo n.º 13
0
class LoginWidget(QDialog, FMainWindow):

    title_page = u"Identification"

    def __init__(self, hibernate=False):
        QDialog.__init__(self)
        self.setWindowTitle(self.set_window_title(self.title_page))
        self.hibernate = hibernate

        self.setWindowFlags(Qt.FramelessWindowHint)
        self.title = FormLabel(
            "<h4>{app_name}</h4><stromg>Ver: {version}</stromg>".format(
                app_name=Config.APP_NAME, version=Config.APP_VERSION))
        self.title.setStyleSheet(
            """ background: url({})#DAF7A6;
                border-radius: 14px 14px 8px 8px; border: 10px double #128a76 ;
                width: 100%; height: auto; padding: 1em;
                font: 8pt 'URW Bookman L';""".format(
                Config.APP_LOGO))
        vbox = QHBoxLayout()

        self.loginUserGroupBox()
        vbox.addWidget(self.title)
        vbox.addWidget(self.topLeftGroupBox)
        # set focus to username field
        self.setFocusProxy(self.password_field)
        self.setLayout(vbox)

    def loginUserGroupBox(self):
        self.topLeftGroupBox = QGroupBox(self.tr("Identification"))

        self.liste_username = Owner.select().where(Owner.isactive == True)
        # Combobox widget
        self.box_username = QComboBox()
        for index in self.liste_username:
            self.box_username.addItem(u'%(username)s' % {'username': index})

        # username field
        self.username_field = self.box_username
        # password field
        self.password_field = EnterTabbedLineEdit()
        self.password_field.setEchoMode(LineEdit.Password)
        self.password_field.setFocus()
        # login button
        self.login_button = QPushButton(u"&S'identifier")
        self.login_button.setIcon(QIcon.fromTheme(
            'save', QIcon(u"{}login.png".format(Config.img_cmedia))))
        self.login_button.clicked.connect(self.login)

        self.cancel_button = QPushButton(u"&Quiter")
        self.cancel_button.clicked.connect(self.cancel)
        self.cancel_button.setFlat(True)

        # login error
        self.login_error = ErrorLabel("")

        formbox = QFormLayout()

        # grid layout
        formbox.addRow(FormLabel(u"Identifiant"), self.username_field)
        formbox.addRow(FormLabel(u"Mot de passe"), self.password_field)
        formbox.addRow(FormLabel(""), self.login_button)
        formbox.addRow(FormLabel(''), self.cancel_button)
        if self.hibernate:
            self.cancel_button.setEnabled(False)

        self.topLeftGroupBox.setLayout(formbox)

    def is_valide(self):
        if check_is_empty(self.password_field):
            return False
        return True

    def cancel(self):
        self.close()

    def login(self):
        """ """
        if not self.is_valide():
            print("is not valide")
            return

        username = str(self.liste_username[self.box_username.currentIndex()])
        password = Owner().crypt_password(
            str(self.password_field.text()).strip())
        # check completeness
        for ow in Owner.select().where(Owner.islog == True):
            ow.islog = False
            ow.save()
        try:
            owner = Owner.get(
                Owner.username == username, Owner.password == password)
            owner.islog = True
            owner.save()
        except Exception as e:
            print(e)
            field_error(self.password_field, "Mot de passe incorrect")
            return False
        self.accept()