Example #1
0
    def add_operation(self):
        ''' add operation '''
        type_ = self.liste_type[self.box_type.currentIndex()]
        magasin = self.liste_magasin[self.box_mag.currentIndex()]
        produit = self.liste_produit[self.box_prod.currentIndex()]
        nbr_carton = self.nbr_carton.text()
        date_ = self.date_.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        datetime_ = datetime(int(year), int(month), int(day),
                             int(dt.hour), int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.nbr_carton.text()) != "":
            r = remaining(type_,  nbr_carton, magasin.id, produit.id)
            if r[0] == None:
                raise_error(_(u"error"), r[1])
            else:
                report = Rapport(unicode(type_), int(nbr_carton), datetime_)
                report.magasin = magasin
                report.produit = produit
                report.restant = r[0]
                session.add(report)
                session.commit()
                self.nbr_carton.clear()
                self.table_op.refresh_()
                raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_(u"error"), _(u"Donnez le nbre de carton"))
Example #2
0
    def add_chiks(self):
        ''' add operation '''

        date_ = self.date_arriver.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        chicken_coop = self.list_chicken_coop[self.chicken_coop.currentIndex()]
        datetime_ = datetime(int(year), int(month), int(day),
                             int(dt.hour), int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.nb_total_chiks.text()) != "" :
            if int(self.nb_total_chiks.text()) >= chicken_coop.nbr_sujet_maxi:
                raise_error(_("Error"), _(u"%s can take only %s chicks") \
                    % (chicken_coop.full_name(), chicken_coop.nbr_sujet_maxi))
            else:
                if chicken_coop.status == 1:
                    raise_error(_("Error"), _(u"%s est occupée") \
                    % (chicken_coop.full_name()))
                else:
                    ps = PsArrivage()
                    ps.race = unicode(self.race.text())
                    ps.nb_total_chiks = int(self.nb_total_chiks.text())
                    ps.arrival_date = datetime_
                    ps.chicken_coop = chicken_coop
                    ps.chicken_coop.status = 1
                    chicken_coop.save()
                    ps.save()
                    self.nb_total_chiks.clear()
                    self.race.clear()
                    self.chiks_table.refresh_()
                    raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_("Error"), _(u"Give the number of the chiks"))
Example #3
0
 def add_operation(self):
     ''' add operation '''
     lib = unicode(self.libelle.text())
     nbr = self.nbre_piece.text()
     if lib != "":
         if unicode(nbr) != "":
             is_double = session.query(Produit)\
                       .filter(Produit.libelle==lib).all() == []
             if is_double:
                 produit = Produit(lib, int(nbr))
                 session.add(produit)
                 session.commit()
                 self.libelle.clear()
                 self.nbre_piece.clear()
                 self.table_op.refresh_()
                 raise_success(_(u"Confirmation"), _(u"The product %s "
                               u" was recorded") % produit.libelle)
             else:
                 raise_error(_(u"error"), \
                             _(u"Ce produit existe déjà"))
         else:
             raise_error(_(u"error"), \
                         _(u"Give the room number in the box"))
     else:
         raise_error(_(u"Error"), _(u"Give the name of the product"))
Example #4
0
    def add_operation(self):
        ''' add operation '''
        type_ = self.liste_type[self.box_type.currentIndex()]
        magasin = self.liste_magasin[self.box_mag.currentIndex()]
        produit = self.liste_produit[self.box_prod.currentIndex()]
        qte_utilise = self.qte_utilise.text()
        date_ = self.date_.text()
        day, month, year = date_.split('/')
        dt = datetime.now()
        datetime_ = datetime(int(year), int(month), int(day),
                             int(dt.hour), int(dt.minute), int(dt.second),
                             int(dt.microsecond))

        if unicode(self.qte_utilise.text()) != "":
            strap = StockRapport()
            strap.type_ = unicode(type_)
            strap.magasin = magasin
            strap.produit = produit
            strap.qte_utilise = int(qte_utilise)
            strap.date_rapp = datetime_
            strap.restant = 0
            strap.save()
            self.qte_utilise.clear()
            self.table_op.refresh_()
            raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_(u"error"), _(u"Give the quantity used"))
Example #5
0
 def edit_prod(self):
     produit = session.query(Produit)\
                      .filter(Produit.libelle == self.prod.libelle) \
                      .filter(Produit.nbr_piece == self.prod.nbr_piece)\
                      .all()[0]
     lib = unicode(self.new_produit.text())
     nbr = self.new_nbr_piece.text()
     if lib != "":
         if unicode(nbr) != "":
             is_double = session.query(Produit)\
                       .filter(Produit.libelle==lib).all() == []
             if is_double:
                 produit = Produit(lib, int(nbr))
                 session.add(produit)
                 session.commit()
                 raise_success(_(u"Confirmation"), _(u"The product has been changing"))
                 self.cancel()
             else:
                 raise_error(_(u"error"), \
                             _(u"Ce produit existe déjà"))
         else:
             raise_error(_(u"error"), \
                         _(u"Give the room number in the box"))
     else:
         raise_error(_(u"Error"), _(u"Give the name of the product"))
Example #6
0
 def edit_mag(self):
     magasin = session.query(Magasin).filter(Magasin.name == self.mag)\
                                     .all()[0]
     magasin.name = unicode(self.new_magasin.text())
     session.add(magasin)
     session.commit()
     self.cancel()
     raise_success(_(u"Confirmation"), _(u"The store has been changing"))
Example #7
0
    def add_operation(self):
        ''' add operation '''

        if unicode(self.name.text()) != "":
            magasin = Magasin(unicode(self.name.text()))
            session.add(magasin)
            session.commit()
            self.name.clear()
            self.stori_table.refresh_()
            raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_("Error"), _(u"Give the name of the store"))
Example #8
0
 def edit_report(self):
     report = self.op
     report.type_ = ""
     report.magasin = ""
     report.produit = ""
     report.nbr_cartion = ""
     #~ session.add(report)
     #~ session.commit()
     #~ update_rapport(self.op)
     self.cancel()
     raise_success(_(u"Confirmation"), \
                         _(u"Your report has been amended"))
Example #9
0
    def add_operation(self):
        ''' add operation '''

        if unicode(self.name.text()) != "":
            magasin = Magasin()
            magasin.name = unicode(self.name.text())
            magasin.qte_maxi_stok = int(self.qte_maxi_stok.text())
            magasin.save()
            self.name.clear()
            self.qte_maxi_stok.clear()
            self.stori_table.refresh_()
            raise_success(_(u"Confirmation"), _(u"Registered operation"))
        else:
            raise_error(_("Error"), _(u"Give the name of the store"))
Example #10
0
    def save_alerte(self):

        date_a = self.date_a.text()
        day, month, year = date_a.split("/")
        dt = datetime.now()
        datetime_ = datetime(
            int(year), int(month), int(day), int(dt.hour), int(dt.minute), int(dt.second), int(dt.microsecond)
        )
        alt = Alerte()
        alt.objets = unicode(self.objets.toPlainText())
        alt.date_a = datetime_
        alt.save()

        self.cancel()
        raise_success(_(u"Confirmation"), _(u"The store has been changing"))
Example #11
0
def export_command_as_excel(comm):

    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(),
                                      _(u"Save Excel Export as..."),
                                    "%s.xls" % datetime.now()
                                        .strftime('%x %Hh%M'), "*.xls")
    if not destination:
        return
    try:
        write_command_xls(destination, comm)
        raise_success(_(u"Success"),
                      _(u"Les données ont été exportées correctement."))
    except IOError:
        raise_error(u"La commande n'a pas pu être exportée.",
                    u"Vérifiez le chemin de destination puis re-essayez.\n\n"
                    u"Demandez de l'aide si le problème persiste.")
Example #12
0
    def save(self):
        """
        Calcul du restant en stock après une operation."""
        from util import raise_success, raise_error

        last_reports = StockRapport.filter(produit__libelle=self
                                           .produit.libelle,
                                           magasin__name=self.magasin.name,
                                           date_rapp__lt=self.date_rapp) \
                                    .order_by(('date_rapp','desc'))
        previous_remaining = 0
        self.restant = 0
        try:
            last_reports = last_reports.get()
        except:
            last_reports = None

        if last_reports == None and self.type_ == _(u"inout"):
            raise_error(_(u"error"), \
                        _(u"Il n'existe aucun %s dans le magasin %s") % \
                        (self.produit.libelle, self.magasin.name))
            return False
        if last_reports:
            previous_remaining = last_reports.restant
            if self.type_ == _(u"input"):
                self.restant = previous_remaining + self.qte_utilise
            if self.type_ == _(u"inout"):
                self.restant = previous_remaining - self.qte_utilise
                if self.restant < 0:
                    print  self.qte_utilise, previous_remaining
                    raise_error(_(u"error"), _(u"On peut pas utilisé %d puis qu'il ne reste que %d") % \
                                       (self.qte_utilise, previous_remaining))
                    return False
        else:
            self.restant = self.qte_utilise
        super(StockRapport, self).save()
        raise_success(_(u"Confirmation"), _(u"Registered operation"))
        # ----------------------------------------------------------------#
        next_reports = StockRapport.filter(produit__libelle=self.produit \
                                .libelle, magasin__name=self.magasin.name, \
                        date__gt=self.date_rapp).order_by(('date_rapp', 'asc'))
        try:
            next_reports = next_reports.get()
        except:
            next_reports = None
        if next_reports:
            next_reports.save()
Example #13
0
def export_database_as_excel():

    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(),
                                    _(u"Save Excel Export as..."),
                                    "%s.xls" % datetime.now()
                                    .strftime(u"%X %Hh%M"), "*.xls")
    if not destination:
        return
    try:
        write_xls(destination)
        raise_success(u"Les données ont été exportées correctement.",
                      u"Conservez ce fichier précieusement car il contient "
                      u"toutes vos données.\n\n"
                      u"Exportez vos données régulièrement.")
    except IOError:
        raise_error(u"La base de données n'a pas pu être exportée.",
                    u"Vérifiez le chemin de destination puis re-essayez.\n\n"
                    u"Demandez de l'aide si le problème persiste.")
Example #14
0
 def add_operation(self):
     ''' add operation '''
     unite_ = self.liste_unite[self.box_unite.currentIndex()]
     if unicode(self.libelle.text()) != "":
         if unicode(unite_) != "":
             produit = Produit()
             produit.libelle = unicode(self.libelle.text())
             produit.unite = unicode(unite_)
             produit.save()
             self.libelle.clear()
             self.table_op.refresh_()
             raise_success(_(u"Confirmation"), _(u"The product %s "
                           u" was recorded") % produit.libelle)
         else:
             raise_error(_(u"error"), \
                         _(u"Give the room number in the box"))
     else:
         raise_error(_(u"Error"), _(u"Give the name of the product"))
Example #15
0
def export_database_as_file():
    destination = QtGui.QFileDialog.getSaveFileName(QtGui.QWidget(),
                                    _(u"Sauvegarder la base de Donnée."),
                                      u"%s.db" % datetime.now()\
                                                .strftime(u'%x-%Hh%M'),
                                    "*.db")
    if not destination:
        return None

    try:
        shutil.copyfile(model.DB_FILE, destination)
        raise_success(u"Les données ont été exportées correctement.",
                      u"Conservez ce fichier précieusement car il "
                      u"contient toutes vos données.\n"
                      u"Exportez vos données régulièrement.")
    except IOError:
        raise_error(u"La base de données n'a pas pu être exportée.",
                    u"Vérifiez le chemin de destination puis re-essayez.\n\n"
                    u"Demandez de l'aide si le problème persiste.")
Example #16
0
    def save(self):
        """
        Calcul du restant en stock après une operation."""
        from util import raise_success, raise_error
        try:
            last_reports = PsRapport.filter(psarrivage__chicken_coop_id= \
                           self.psarrivage).order_by(('date_report', 'desc'))
        except:
            raise_error(_("Error"), _(u"Ce poulailler est vide"))
            return False
        previous_remaining = 0
        self.remaining = 0
        try:
            last_report = last_reports.get()
        except:
            last_report = None

        if last_report:
            previous_remaining = last_report.remaining
            self.remaining = previous_remaining - self.nb_death
            if self.remaining < 0:
                raise_error(_(u"error"), \
                    _(u"On peut pas utilisé %d puis qu'il ne reste que %d") % \
                    (self.nb_death, previous_remaining))
                return False
        else:
            self.remaining = self.psarrivage.nb_total_chiks - self.nb_death

        super(PsRapport, self).save()
        raise_success(_(u"Confirmation"), _(u"Registered operation"))
        # ----------------------------------------------------------------#
        next_reports = PsRapport.filter(psarrivage=self.psarrivage, \
                                        date_report__gt=self.date_report) \
                                .order_by(('date_report', 'asc'))

        try:
            next_reports = next_reports.get()
        except:
            next_reports = None

        if next_reports:
            next_reports.save()
Example #17
0
 def add_chickencoop(self):
     ''' add operation '''
     date_ = self.date.text()
     day, month, year = date_.split('/')
     dt = datetime.now()
     datetime_ = datetime(int(year), int(month), int(day),
                          int(dt.hour), int(dt.minute), int(dt.second),
                          int(dt.microsecond))
     if unicode(self.num.text()) != "":
         poussin = ChickenCoop()
         poussin.type_ = int(self.type_.currentIndex())
         poussin.num = int(self.num.text())
         poussin.nbr_sujet_maxi = int(self.nbr_sujet_maxi.text())
         poussin.date = datetime_
         poussin.save()
         self.num.clear()
         self.nbr_sujet_maxi.clear()
         self.poussin_table.refresh_()
         raise_success(_(u"Confirmation"), _(u"Registered operation"))
     else:
         raise_error(_("Error"), _(u"Give the name of the store"))
Example #18
0
 def delete(self):
     session.delete(self.op)
     session.commit()
     update_rapport(self.op)
     self.cancel()
     raise_success(_(u"Confirmation"), _(u"Your report has been deleted"))