forked from DGNum/gestioCOF
Fournisseur
- Liste des fournisseurs sur la page commande (`/orders/`) - Possibilité d'éditer les infos d'un fournisseur depuis cette page - Ajout vérification permission pour enregistrer un inventaire - Fix messages sur vue inventaire create
This commit is contained in:
parent
a0f1243690
commit
d531c7dd5b
5 changed files with 136 additions and 4 deletions
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% include 'kfet/base_messages.html' %}
|
||||||
|
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
|
|
62
kfet/templates/kfet/order.html
Normal file
62
kfet/templates/kfet/order.html
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
{% extends 'kfet/base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Commandes{% endblock %}
|
||||||
|
{% block content-header-title %}Commandes{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-4 col-md-3 col-content-left">
|
||||||
|
<div class="content-left">
|
||||||
|
<div class="content-left-top">
|
||||||
|
</div>
|
||||||
|
<div class="buttons">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-8 col-md-9 col-content-right">
|
||||||
|
{% include 'kfet/base_messages.html' %}
|
||||||
|
<div class="content-right">
|
||||||
|
<div class="content-right-block">
|
||||||
|
<h2>Liste des commandes</h2>
|
||||||
|
<div>
|
||||||
|
<table>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="content-right-block">
|
||||||
|
<h2>Fournisseurs</h2>
|
||||||
|
<div>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>Nom</td>
|
||||||
|
<td>Mail</td>
|
||||||
|
<td>Tél.</td>
|
||||||
|
<td>Adresse</td>
|
||||||
|
<td>Commentaire</td>
|
||||||
|
<tbody>
|
||||||
|
{% for supplier in suppliers %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{% url 'kfet.order.supplier.update' supplier.pk %}">
|
||||||
|
<span class="glyphicon glyphicon-cog"></span>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>{{ supplier.name }}</td>
|
||||||
|
<td>{{ supplier.email }}</td>
|
||||||
|
<td>{{ supplier.phone }}</td>
|
||||||
|
<td>{{ supplier.address }}</td>
|
||||||
|
<td>{{ supplier.comment }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
19
kfet/templates/kfet/supplier_form.html
Normal file
19
kfet/templates/kfet/supplier_form.html
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{% extends 'kfet/base.html' %}
|
||||||
|
|
||||||
|
{% block title %}Fournisseur - Modification{% endblock %}
|
||||||
|
{% block content-header-title %}Fournisseur - Modification{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% include 'kfet/base_messages.html' %}
|
||||||
|
|
||||||
|
<form action="" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form.as_p }}
|
||||||
|
{% if not perms.kfet.change_supplier %}
|
||||||
|
<input type="password" name="KFETPASSWORD">
|
||||||
|
{% endif %}
|
||||||
|
<input type="submit" class="btn btn-primary btn-lg">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
12
kfet/urls.py
12
kfet/urls.py
|
@ -164,10 +164,22 @@ urlpatterns = [
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
# Inventories urls
|
# Inventories urls
|
||||||
|
# -----
|
||||||
|
|
||||||
url(r'^inventaires/$',
|
url(r'^inventaires/$',
|
||||||
permission_required('kfet.is_team')(views.InventoryList.as_view()),
|
permission_required('kfet.is_team')(views.InventoryList.as_view()),
|
||||||
name = 'kfet.inventory'),
|
name = 'kfet.inventory'),
|
||||||
url(r'^inventaires/new$', views.inventory_create,
|
url(r'^inventaires/new$', views.inventory_create,
|
||||||
name = 'kfet.inventory.create'),
|
name = 'kfet.inventory.create'),
|
||||||
|
|
||||||
|
# -----
|
||||||
|
# Order urls
|
||||||
|
# -----
|
||||||
|
|
||||||
|
url(r'^orders/$',
|
||||||
|
permission_required('kfet.is_team')(views.OrderList.as_view()),
|
||||||
|
name = 'kfet.order'),
|
||||||
|
url(r'^orders/suppliers/(?P<pk>\d+)/edit$',
|
||||||
|
permission_required('kfet.is_team')(views.SupplierUpdate.as_view()),
|
||||||
|
name = 'kfet.order.supplier.update'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -19,7 +19,7 @@ from django.utils.crypto import get_random_string
|
||||||
from gestioncof.models import CofProfile, Clipper
|
from gestioncof.models import CofProfile, Clipper
|
||||||
from kfet.models import (Account, Checkout, Article, Settings, AccountNegative,
|
from kfet.models import (Account, Checkout, Article, Settings, AccountNegative,
|
||||||
CheckoutStatement, GenericTeamToken, Supplier, SupplierArticle, Inventory,
|
CheckoutStatement, GenericTeamToken, Supplier, SupplierArticle, Inventory,
|
||||||
InventoryArticle)
|
InventoryArticle, Order)
|
||||||
from kfet.forms import *
|
from kfet.forms import *
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from kfet import consumers
|
from kfet import consumers
|
||||||
|
@ -1310,7 +1310,10 @@ def inventory_create(request):
|
||||||
|
|
||||||
if request.POST:
|
if request.POST:
|
||||||
formset = cls_formset(request.POST, initial=initial)
|
formset = cls_formset(request.POST, initial=initial)
|
||||||
if formset.is_valid():
|
|
||||||
|
if not request.user.has_perm('kfet.add_inventory'):
|
||||||
|
messages.error(request, 'Permission refusée')
|
||||||
|
elif formset.is_valid():
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
|
||||||
articles = Article.objects.select_for_update()
|
articles = Article.objects.select_for_update()
|
||||||
|
@ -1332,12 +1335,46 @@ def inventory_create(request):
|
||||||
stock_new = stock_new)
|
stock_new = stock_new)
|
||||||
article.stock = stock_new
|
article.stock = stock_new
|
||||||
article.save()
|
article.save()
|
||||||
print('ok')
|
if saved:
|
||||||
|
messages.success(request, 'Inventaire créé')
|
||||||
|
return redirect('kfet.inventory')
|
||||||
|
messages.warning(request, 'Bah alors ? On a rien compté ?')
|
||||||
else:
|
else:
|
||||||
messages.error('Pas marché')
|
messages.error(request, 'Pas marché')
|
||||||
else:
|
else:
|
||||||
formset = cls_formset(initial = initial)
|
formset = cls_formset(initial = initial)
|
||||||
|
|
||||||
return render(request, 'kfet/inventory_create.html', {
|
return render(request, 'kfet/inventory_create.html', {
|
||||||
'formset': formset,
|
'formset': formset,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
# -----
|
||||||
|
# Order views
|
||||||
|
# -----
|
||||||
|
|
||||||
|
class OrderList(ListView):
|
||||||
|
model = Order
|
||||||
|
template_name = 'kfet/order.html'
|
||||||
|
context_object_name = 'inventories'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(OrderList, self).get_context_data(**kwargs)
|
||||||
|
context['suppliers'] = Supplier.objects.order_by('name')
|
||||||
|
return context
|
||||||
|
|
||||||
|
class SupplierUpdate(SuccessMessageMixin, UpdateView):
|
||||||
|
model = Supplier
|
||||||
|
template_name = 'kfet/supplier_form.html'
|
||||||
|
fields = ['name', 'address', 'email', 'phone', 'comment']
|
||||||
|
success_url = reverse_lazy('kfet.order')
|
||||||
|
sucess_message = 'Données fournisseur mis à jour'
|
||||||
|
|
||||||
|
# Surcharge de la validation
|
||||||
|
def form_valid(self, form):
|
||||||
|
# Checking permission
|
||||||
|
if not self.request.user.has_perm('kfet.change_supplier'):
|
||||||
|
form.add_error(None, 'Permission refusée')
|
||||||
|
return self.form_invalid(form)
|
||||||
|
# Updating
|
||||||
|
return super(SupplierUpdate, self).form_valid(form)
|
||||||
|
|
Loading…
Reference in a new issue