Page détails inventaire

This commit is contained in:
Aurélien Delobelle 2016-08-30 23:32:54 +02:00
parent a59dabd114
commit 42cca8f9cf
5 changed files with 90 additions and 4 deletions

View file

@ -37,7 +37,7 @@
{% for inventory in inventories %}
<tr>
<td class="text-center">
<a href="">
<a href="{% url 'kfet.inventory.read' inventory.pk %}">
<span class="glyphicon glyphicon-cog"></span>
</a>
</td>

View file

@ -0,0 +1,62 @@
{% extends 'kfet/base.html' %}
{% block title %}Inventaire #{{ inventory.pk }}{% endblock %}
{% block content-header-title %}Inventaire #{{ inventory.pk }}{% 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 class="line"><b>Date:</b> {{ inventory.at }}</div>
<div class="line"><b>Par:</b> {{ inventory.by.trigramme }}</div>
{% if inventory.order %}
<div class="line">
<b>Commande relative:</b>&nbsp;
<a href="{% url 'kfet.order.read' inventory.order.pk %}">
#{{ inventory.order.pk }}
</a>
</div>
{% endif %}
</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>Détails</h2>
<div class="table-responsive">
<table class="table table-condensed">
<thead>
<tr>
<td>Article</td>
<td>Stock avant</td>
<td>Stock après</td>
<td>Erreur</td>
</tr>
</thead>
<tbody>
{% for inventoryart in inventoryarts %}
{% ifchanged inventoryart.article.category %}
<tr class="section">
<td colspan="4">{{ inventoryart.article.category.name }}</td>
</tr>
{% endifchanged %}
<tr>
<td>{{ inventoryart.article.name }}</td>
<td>{{ inventoryart.stock_old }}</td>
<td>{{ inventoryart.stock_new }}</td>
<td>{{ inventoryart.stock_error }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -9,6 +9,8 @@
<div class="col-sm-4 col-md-3 col-content-left">
<div class="content-left">
<div class="content-left-top">
<div class="line line-big">{{ orders|length }}</div>
<div class="line line-bigsub">commande{{ orders|length|pluralize }}</div>
</div>
<div class="buttons">
</div>
@ -64,15 +66,14 @@
<td></td>
<td>Date</td>
<td>Fournisseur</td>
<td>Inventaire</td>
</tr>
</thead>
<tbody>
{% for order in orders %}
<tr>
<td class="no-padding">
{% if order.inventory %}
<a href="" class="btn btn-primary">Inventaire</a>
{% else %}
{% if not order.inventory %}
<a href="{% url 'kfet.order.to_inventory' order.pk %}" class="btn btn-primary">
Générer inventaire
</a>
@ -85,6 +86,13 @@
</td>
<td>{{ order.at }}</td>
<td>{{ order.supplier }}</td>
<td>
{% if order.inventory %}
<a href="{% url 'kfet.inventory.read' order.inventory.pk %}">
#{{ order.inventory.pk }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>

View file

@ -171,6 +171,9 @@ urlpatterns = [
name = 'kfet.inventory'),
url(r'^inventaires/new$', views.inventory_create,
name = 'kfet.inventory.create'),
url(r'^inventaires/(?P<pk>\d+)$',
permission_required('kfet.is_team')(views.InventoryRead.as_view()),
name = 'kfet.inventory.read'),
# -----
# Order urls

View file

@ -1390,6 +1390,19 @@ def inventory_create(request):
'formset': formset,
})
class InventoryRead(DetailView):
model = Inventory
template_name = 'kfet/inventory_read.html'
context_object_name = 'inventory'
def get_context_data(self, **kwargs):
context = super(InventoryRead, self).get_context_data(**kwargs)
inventoryarticles = (InventoryArticle.objects
.select_related('article', 'article__category')
.filter(inventory = self.object)
.order_by('article__category__name', 'article__name'))
context['inventoryarts'] = inventoryarticles
return context
# -----
# Order views