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()]
        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 #2
0
#!/usr/bin/env python
# encoding= utf-8
#maintainer : Fad

from datetime import datetime
from model import Magasin, StockRapport, Produit

m = Magasin(name=u"magasin aliment", qte_maxi_stok=5000)
m.save()
p = Produit(libelle=u"poisson", unite="kg")
p.save()

print "produit", Produit.all()
print "magasin", Magasin.all()

sr = StockRapport()
sr.type_ = "poulailler"
sr.magasin = 1
sr.produit = 1
sr.qte_utilise = 50
sr.restant = 20
sr.date_rapp = datetime.now()
sr.registered_on = datetime.now()
sr.save()

print "rapport pour les stocks ",  StockRapport.all()