kfetTriArticles

This commit is contained in:
Quentin VERMANDE 2020-12-09 22:03:54 +01:00
parent 340f8f16a7
commit 9d2c13e67c
4 changed files with 43 additions and 25 deletions

View file

@ -558,6 +558,7 @@ class InventoryArticleForm(forms.Form):
self.category = kwargs["initial"]["category"]
self.category_name = kwargs["initial"]["category__name"]
self.box_capacity = kwargs["initial"]["box_capacity"]
self.is_sold = kwargs["initial"]["is_sold"]
# -----
@ -584,6 +585,7 @@ class OrderArticleForm(forms.Form):
self.v_et = kwargs["initial"]["v_et"]
self.v_prev = kwargs["initial"]["v_prev"]
self.c_rec = kwargs["initial"]["c_rec"]
self.is_sold = kwargs["initial"]["is_sold"]
class OrderArticleToInventoryForm(forms.Form):

View file

@ -26,6 +26,12 @@
</thead>
<tbody>
{% for form in formset %}
{% ifchanged form.is_sold %}
<tr class='section'>
<td>{% if form.is_sold %} Vendu {% else %} Non vendu {% endif %}</td>
<td colspan="7"></td>
</tr>
{% endifchanged %}
{% ifchanged form.category %}
<tr class='section'>
<td>{{ form.category_name }}</td>

View file

@ -58,31 +58,39 @@
{% endfor %}
</tr>
</thead>
{% regroup formset by category_name as category_list %}
{% for category in category_list %}
<tbody class="tablesorter-no-sort">
<tr class='section text-left'>
<td colspan="{{ scale|length|add:'8' }}">{{ category.grouper }}</td>
{% regroup formset by is_sold as is_sold_list %}
{% for condition in is_sold_list %}
<tbody class="tablesorter-no-sort">
<tr class='section text-center'>
<td colspan="{{ scale|length|add:'8' }}">{% if condition.grouper %} Vendu {% else %} Non vendu {% endif %}</td>
</tr>
</tbody>
<tbody>
{% for form in category.list %}
<tr>
{{ form.article }}
<td class="text-left">{{ form.name }}</td>
{% for v_chunk in form.v_all %}
<td>{{ v_chunk }}</td>
{% endfor %}
<td>{{ form.v_moy }}</td>
<td>{{ form.v_et }}</td>
<td>{{ form.v_prev }}</td>
<td>{{ form.stock }}</td>
<td>{{ form.box_capacity|default:"" }}</td>
<td>{{ form.c_rec }}</td>
<td class="nopadding">{{ form.quantity_ordered|add_class:"form-control" }}</td>
</tr>
{% endfor %}
</tbody>
{% regroup condition.list by category_name as category_list %}
{% for category in category_list %}
<tbody class="tablesorter-no-sort">
<tr class='section text-left'>
<td colspan="{{ scale|length|add:'8' }}">{{ category.grouper }}</td>
</tr>
</tbody>
<tbody>
{% for form in category.list %}
<tr>
{{ form.article }}
<td class="text-left">{{ form.name }}</td>
{% for v_chunk in form.v_all %}
<td>{{ v_chunk }}</td>
{% endfor %}
<td>{{ form.v_moy }}</td>
<td>{{ form.v_et }}</td>
<td>{{ form.v_prev }}</td>
<td>{{ form.stock }}</td>
<td>{{ form.box_capacity|default:"" }}</td>
<td>{{ form.c_rec }}</td>
<td class="nopadding">{{ form.quantity_ordered|add_class:"form-control" }}</td>
</tr>
{% endfor %}
</tbody>
{% endfor %}
{% endfor %}
</table>
</div>

View file

@ -1835,12 +1835,13 @@ class InventoryList(ListView):
def inventory_create(request):
articles = Article.objects.select_related("category").order_by(
"category__name", "name"
"-is_sold", "category__name", "name"
)
initial = []
for article in articles:
initial.append(
{
"is_sold": article.is_sold,
"article": article.pk,
"stock_old": article.stock,
"name": article.name,
@ -1960,7 +1961,7 @@ def order_create(request, pk):
Article.objects.filter(suppliers=supplier.pk)
.distinct()
.select_related("category")
.order_by("category__name", "name")
.order_by("-is_sold", "category__name", "name")
)
# Force hit to cache
@ -2017,6 +2018,7 @@ def order_create(request, pk):
"v_et": round(v_et),
"v_prev": round(v_prev),
"c_rec": article.box_capacity and c_rec or round(c_rec_tot),
"is_sold": article.is_sold
}
)