Add first improvements for inventory
This commit is contained in:
parent
f063c3470c
commit
3b793dc726
3 changed files with 86 additions and 33 deletions
|
@ -457,7 +457,13 @@ class InventoryArticleForm(forms.Form):
|
|||
queryset = Article.objects.all(),
|
||||
widget = forms.HiddenInput(),
|
||||
)
|
||||
stock_new = forms.IntegerField(required = False)
|
||||
stock_new = forms.IntegerField(
|
||||
required=False,
|
||||
widget=forms.NumberInput(
|
||||
attrs={'class': 'form-control',
|
||||
'readonly': '',}
|
||||
)
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(InventoryArticleForm, self).__init__(*args, **kwargs)
|
||||
|
@ -466,6 +472,7 @@ class InventoryArticleForm(forms.Form):
|
|||
self.stock_old = kwargs['initial']['stock_old']
|
||||
self.category = kwargs['initial']['category']
|
||||
self.category_name = kwargs['initial']['category__name']
|
||||
self.box_capacity = kwargs['initial']['box_capacity']
|
||||
|
||||
# -----
|
||||
# Order forms
|
||||
|
|
|
@ -6,38 +6,83 @@
|
|||
{% block content %}
|
||||
|
||||
{% include 'kfet/base_messages.html' %}
|
||||
|
||||
<form action="" method="post">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Article</td>
|
||||
<td>Théo.</td>
|
||||
<td>Réel</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for form in formset %}
|
||||
{% ifchanged form.category %}
|
||||
<div class="content-center">
|
||||
<div>
|
||||
<form action="" method="post">
|
||||
<table class="table text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<td colspan="3">{{ form.category_name }}</td>
|
||||
<td>Article</td>
|
||||
<td>Quantité par caisse</td>
|
||||
<td>Stock Théorique</td>
|
||||
<td>Caisses en réserve</td>
|
||||
<td>Caisses en arrière</td>
|
||||
<td>Vrac</td>
|
||||
<td>Stock total</td>
|
||||
</tr>
|
||||
{% endifchanged %}
|
||||
<tr>
|
||||
{{ form.article }}
|
||||
<td>{{ form.name }}</td>
|
||||
<td>{{ form.stock_old }}</td>
|
||||
<td>{{ form.stock_new }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% if not perms.kfet.add_inventory %}
|
||||
<input type="password" name="KFETPASSWORD">
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
{{ formset.management_form }}
|
||||
<input type="submit" value="Enregistrer" class="btn btn-primary btn-lg">
|
||||
</form>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for form in formset %}
|
||||
{% ifchanged form.category %}
|
||||
<tr class='section'>
|
||||
<td>{{ form.category_name }}</td>
|
||||
<td colspan="6"></td>
|
||||
</tr>
|
||||
{% endifchanged %}
|
||||
<tr>
|
||||
{{ form.article }}
|
||||
<td>{{ form.name }}</td>
|
||||
<td id='id_{{form.prefix}}-box_capacity'>{{ form.box_capacity }}</td>
|
||||
<td>{{ form.stock_old }}</td>
|
||||
<td>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'>
|
||||
<input type='number' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-box_cellar' step='1'>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'><input type='number' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-box_bar' step='1'></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'><input type='number' prefix='{{form.prefix}}' class='form-control' id='id_{{form.prefix}}-misc' step='1'></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class='col-md-2'></div>
|
||||
<div class='col-md-8'>{{ form.stock_new }}</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{{ formset.management_form }}
|
||||
{% if not perms.kfet.add_inventory %}
|
||||
<td colspan='3'><label for='pwd'>Mot de passe : </label><input type="password" name="KFETPASSWORD"></td>
|
||||
<td colspan='4'><input type="submit" value="Enregistrer" class="btn btn-primary btn-lg btn-block"></td>
|
||||
{% else %}
|
||||
<td colspan='7'><input type="submit" value="Enregistrer" class="btn btn-primary btn-lg btn-block"></td>
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
</form>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
$('input[type="number"]').on('input', function() {
|
||||
var prefix = $(this).attr('prefix');
|
||||
var $line = $(this).closest('tr');
|
||||
var box_capacity = +$line.find('#id_'+prefix+'-box_capacity').text();
|
||||
var box_cellar = +$line.find('#id_'+prefix+'-box_cellar').val();
|
||||
var box_bar = +$line.find('#id_'+prefix+'-box_bar').val();
|
||||
var misc = +$line.find('#id_'+prefix+'-misc').val();
|
||||
$line.find('#id_'+prefix+'-stock_new').val(box_capacity*(box_cellar +box_bar)+misc);
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -1658,7 +1658,8 @@ def inventory_create(request):
|
|||
'stock_old': article.stock,
|
||||
'name' : article.name,
|
||||
'category' : article.category_id,
|
||||
'category__name': article.category.name
|
||||
'category__name': article.category.name,
|
||||
'box_capacity': article.box_capacity or 0,
|
||||
})
|
||||
|
||||
cls_formset = formset_factory(
|
||||
|
|
Loading…
Reference in a new issue