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"))
#!/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()