Ejemplo n.º 1
0
def create_commande_fournisseur(request):
    # Try to get the Client interne Option
    try:
        client = Option.get('Client interne')
        client = Client.objects.filter(Nom = client)[0:1].get()
    except:
        raise Exception("Impossible de faire une commande fournisseur sans l'option Client interne ")
    
    facture = Facture()
    d = datetime.today()
    facture.Note = "Commande fournisseur du " + str(d.year) +'/'+ str(d.month) +'/'+ str(d.day)
    facture.Client = client
    facture.save()
    
    return facture
Ejemplo n.º 2
0
def CreerFacture(request):
    created = False
    facture = False
    # Special case for restricted users, see README for more
    user = BiereUser.as_current_user()
    client = user.is_restricted_user()
    if client:
        facture = Facture()
        facture.Client = client
        d = datetime.today()
        facture.Note = "Facture du " + str(d.year) +'/'+ str(d.month) +'/'+ str(d.day)
        facture.save()
        
        return HttpResponseRedirect('/factures/'+ str(facture.id)+'/')
        
        
    # There is a new commande to create
    if request.method == 'POST':
        factureform = FactureForm(request.POST)
        if factureform.is_valid():
            bill 		        = factureform.save( commit=False )
            bill.User           = request.user
            bill.save()
            created 	        = True
            facture				= bill
    else:
        try:
            if request.GET['client']: 
                id = int(request.GET['client'])
                factureform = FactureForm(initial={'Client': id})
            else: 
                factureform = FactureForm()
        except Exception as e:
                print e
                factureform = FactureForm()

        facture 	= Facture() 
        commande    = False
        produits    = False
		
    return render_to_response('facture/new.html', {'created':created, 'factureform': factureform, 'user': request.user, 'facture': facture })