def OnVerifiee(self, event): if self.commande: commande_verifiee = True for lc in self.liste_lignes_commande.GetObjects(): if not lc.is_verifiee: commande_verifiee = False if commande_verifiee: dlg = wx.MessageDialog(parent=None, message=u"La livraison a bien été vérifiée ?", caption=u"Vérification de la livraison", style=wx.YES_NO|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: for lc in self.liste_lignes_commande.GetObjects(): lc.save() self.commande.statut = 3 self.commande.save() self.liste_commandes.RefreshObject(self.commande) self.OnSelectionCommande(None) with DATABASE.transaction(): DATABASE.commit() dlg.Destroy() else: wx.MessageBox(u"La livraison n'a pas encoré été entièrement vérifiée", "Erreur", style=wx.ICON_ERROR)
def OnEnregistre(self, event): if self.Validate(): self.panel_adherent.Enregistre() DATABASE.commit() event.Skip() else: control = wx.Window.FindFocus() self.notebook.ChangeSelection(0) control.SetFocus()
def OnEnregistre(self, event): if self.Validate(): self.panel_fournisseur.Enregistre() DATABASE.commit() event.Skip() else: control = wx.Window.FindFocus() self.notebook.ChangeSelection(0) control.SetFocus()
def OnSauvegarder(self, event): try: date_commande = self.datepicker_date_commande.GetValue() print datetime(date_commande.GetYear(), date_commande.GetMonth()+1, date_commande.GetDay()) self.commande.date_commande = datetime(date_commande.GetYear(), date_commande.GetMonth()+1, date_commande.GetDay()) self.commande.save() DATABASE.commit() wx.MessageBox(u"La commande a été enregistrée", "Notification") except BaseException as ex: wx.MessageBox(u"Problème lors de l'enregistrement : %s" % ex, "Erreur")
def OnCommandee(self, event): if self.commande: dlg = wx.MessageDialog(parent=None, message=u"La commande a bien été commandée ?", caption=u"Commande de la commande", style=wx.YES_NO|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.commande.statut = 1 self.commande.save() self.liste_commandes.RefreshObject(self.commande) self.OnSelectionCommande(None) DATABASE.commit() dlg.Destroy()
def OnEmail(self, event): if self.commande: if self.commande.statut < 2: envoi_email = EnvoiEmailCommande(self, self.commande) envoi_email.ShowModal() envoi_email.Destroy() if envoi_email.ShowModal() == wx.ID_OK: self.commande.statut(1) self.commande.save() self.liste_commandes.RefreshObject(self.commande) self.OnSelectionCommande(None) DATABASE.commit()
def OnSauvegarder(self, event): if self.Validate(): cotisation = self.achat.adherent.paye_cotisation_du_mois() cotisation.save() self.achat.date = datetime.today() if self.text_cout_supplementaire.GetValue(): self.achat.cout_supplementaire = float(self.text_cout_supplementaire.GetValue()) else: self.achat.cout_supplementaire = 0 self.achat.cout_supplementaire_commentaire = self.text_cout_supplementaire_commentaire.GetValue() self.achat.save() DATABASE.commit() wx.MessageBox(u"L'achat a été enregistré", "Notification") self.EndModal(wx.ID_SAVE)
def OnLivree(self, event): #TODO : ajouter la possibilité de choisir la date de livraison #Ajouter également une vérification sur les prix if self.commande: dlg = wx.MessageDialog(parent=None, message=u"La commande a bien été livrée ?", caption=u"Livraison de la commande", style=wx.YES_NO|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.commande.statut = 2 self.commande.save() self.liste_commandes.RefreshObject(self.commande) self.OnSelectionCommande(None) DATABASE.commit() dlg.Destroy()
def OnDestroy(self, event): if not self.inventaire.is_valide: dlg = wx.MessageDialog(parent=None, message=u"Voulez vous sauvegarder l'inventaire ?", caption=u"Sauvegarde de l'inventaire", style=wx.YES_NO|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_YES: self.inventaire.date = date.today() self.inventaire.save() DATABASE.commit() else: DATABASE.rollback() dlg.Destroy() event.Skip()
def OnSauvegarder(self, event): if self.Validate(): cotisation = self.achat.adherent.paye_cotisation_du_mois() cotisation.save() self.achat.date = datetime.today() if self.text_cout_supplementaire.GetValue(): self.achat.cout_supplementaire = float( self.text_cout_supplementaire.GetValue()) else: self.achat.cout_supplementaire = 0 self.achat.cout_supplementaire_commentaire = self.text_cout_supplementaire_commentaire.GetValue( ) self.achat.save() DATABASE.commit() wx.MessageBox(u"L'achat a été enregistré", "Notification") self.EndModal(wx.ID_SAVE)
def OnSupprimer(self, event): if self.commande: if self.commande.statut == 0: dlg = wx.MessageDialog(parent=None, message=u"Voulez vous vraiment supprimer la commande ?", caption=u"Suppression de la commande", style=wx.OK|wx.CANCEL|wx.ICON_QUESTION) if dlg.ShowModal() == wx.ID_OK: self.liste_commandes.RemoveObject(self.commande) self.liste_lignes_commande.SetObjects(None) self.commande.delete_instance(recursive=True) self.commande = None self.OnSelectionCommande(None) DATABASE.commit()
def OnSauvegarder(self, event): try: date_commande = self.datepicker_date_commande.GetValue() print datetime(date_commande.GetYear(), date_commande.GetMonth() + 1, date_commande.GetDay()) self.commande.date_commande = datetime( date_commande.GetYear(), date_commande.GetMonth() + 1, date_commande.GetDay()) self.commande.save() DATABASE.commit() wx.MessageBox(u"La commande a été enregistrée", "Notification") except BaseException as ex: wx.MessageBox(u"Problème lors de l'enregistrement : %s" % ex, "Erreur")
def OnImpressionEtiquettes(self, event): lst = [] ligne_etiquettes = [] tableau_etiquettes = [] tableau_style = [] hauteurs_lignes = [] tableau_style.append(('VALIGN', (0, 0), (-1, -1), 'MIDDLE')) tableau_style.append(('TOPPADDING', (0, 0), (-1, -1), 0)) tableau_style.append(('BOTTOMPADDING', (0, 0), (-1, -1), 0)) tableau_style.append(('LEFTPADDING', (0, 0), (-1, -1), 2)) tableau_style.append(('RIGHTPADDING', (0, 0), (-1, -1), 2)) tableau_style.append(('BOX', (0, 0), (-1, -1), 2, colors.black)) tableau_style.append(('INNERGRID', (0, 0), (-1, -1), 2, colors.black)) n_produit = 0 ref_style = ParagraphStyle('RefProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=14) nom_style = ParagraphStyle('NomProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=12) prix_style = ParagraphStyle('PrixProduit', alignment=TA_CENTER, leading=16, fontName='Helvetica-Bold', fontSize=14) liste_produits_etiquettes = [] for produit in self.liste_produits.GetObjects(): if produit.a_etiquetter: n_produit += 1 if n_produit%2 == 0: x = 3 else: x = 0 y = (n_produit-1)/2 ligne_etiquettes.append(Paragraph(produit.ref_GASE, ref_style)) ligne_etiquettes.append(Paragraph(produit.nom, nom_style)) ligne_etiquettes.append(Paragraph(produit.prix_vente_format, prix_style)) tableau_style.append(('BACKGROUND', (x, y), (x+2, y), produit.fournisseur.couleur)) if n_produit%2 == 0: tableau_etiquettes.append(ligne_etiquettes) hauteurs_lignes.append(2*cm) ligne_etiquettes = [] produit.a_etiquetter = False liste_produits_etiquettes.append(produit) #Si aucun produit n'est selectionnee on ne continue pas if n_produit > 0: if n_produit%2 != 0: ligne_etiquettes.append("") ligne_etiquettes.append("") ligne_etiquettes.append("") tableau_etiquettes.append(ligne_etiquettes) hauteurs_lignes.append(2*cm) table_etiquettes = Table(tableau_etiquettes, colWidths=[2*cm, 5.5*cm, 2*cm, 2*cm, 5.5*cm, 2*cm], rowHeights=hauteurs_lignes) table_etiquettes.setStyle(TableStyle(tableau_style)) lst.append(table_etiquettes) #Création des répertoires si ils n'existent pas rep = os.path.dirname(os.getcwd() + "/Etiquettes/") if not os.path.exists(rep): os.makedirs(rep) date_jour = datetime.now() chemin_fichier = os.path.join(rep, "Etiquettes - " + date_jour.strftime("%d-%m-%Y %H-%M-%S") + ".pdf") doc = SimpleDocTemplate(chemin_fichier, title="Etiquettes - " + date_jour.strftime("%d-%m-%Y %H-%M-%S"), pagesize=A4, topMargin=2*cm, bottomMargin=2*cm, leftMargin=1.5*cm, rightMargin=1.5*cm) doc.build(lst) #session.commit() self.liste_produits.RefreshObjects(self.liste_produits.GetObjects()) '''preview_pdf = PreviewPDF(chemin_fichier) preview_pdf.ShowModal() preview_pdf.Destroy()''' desktop.open(chemin_fichier) try: for p in liste_produits_etiquettes: p.save() DATABASE.commit() except: DATABASE.rollback()