Add first improvements for inventory
This commit is contained in:
parent
f063c3470c
commit
3b793dc726
|
@ -457,7 +457,13 @@ class InventoryArticleForm(forms.Form):
|
||||||
queryset = Article.objects.all(),
|
queryset = Article.objects.all(),
|
||||||
widget = forms.HiddenInput(),
|
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):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InventoryArticleForm, self).__init__(*args, **kwargs)
|
super(InventoryArticleForm, self).__init__(*args, **kwargs)
|
||||||
|
@ -466,6 +472,7 @@ class InventoryArticleForm(forms.Form):
|
||||||
self.stock_old = kwargs['initial']['stock_old']
|
self.stock_old = kwargs['initial']['stock_old']
|
||||||
self.category = kwargs['initial']['category']
|
self.category = kwargs['initial']['category']
|
||||||
self.category_name = kwargs['initial']['category__name']
|
self.category_name = kwargs['initial']['category__name']
|
||||||
|
self.box_capacity = kwargs['initial']['box_capacity']
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
# Order forms
|
# Order forms
|
||||||
|
|
|
@ -6,38 +6,83 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% include 'kfet/base_messages.html' %}
|
{% include 'kfet/base_messages.html' %}
|
||||||
|
<div class="content-center">
|
||||||
<form action="" method="post">
|
<div>
|
||||||
<table>
|
<form action="" method="post">
|
||||||
|
<table class="table text-center">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Article</td>
|
<td>Article</td>
|
||||||
<td>Théo.</td>
|
<td>Quantité par caisse</td>
|
||||||
<td>Réel</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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for form in formset %}
|
{% for form in formset %}
|
||||||
{% ifchanged form.category %}
|
{% ifchanged form.category %}
|
||||||
<tr>
|
<tr class='section'>
|
||||||
<td colspan="3">{{ form.category_name }}</td>
|
<td>{{ form.category_name }}</td>
|
||||||
|
<td colspan="6"></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endifchanged %}
|
{% endifchanged %}
|
||||||
<tr>
|
<tr>
|
||||||
{{ form.article }}
|
{{ form.article }}
|
||||||
<td>{{ form.name }}</td>
|
<td>{{ form.name }}</td>
|
||||||
|
<td id='id_{{form.prefix}}-box_capacity'>{{ form.box_capacity }}</td>
|
||||||
<td>{{ form.stock_old }}</td>
|
<td>{{ form.stock_old }}</td>
|
||||||
<td>{{ form.stock_new }}</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>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
{{ formset.management_form }}
|
||||||
</table>
|
|
||||||
{% if not perms.kfet.add_inventory %}
|
{% if not perms.kfet.add_inventory %}
|
||||||
<input type="password" name="KFETPASSWORD">
|
<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 %}
|
{% endif %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ formset.management_form }}
|
</form>
|
||||||
<input type="submit" value="Enregistrer" class="btn btn-primary btn-lg">
|
</tbody>
|
||||||
</form>
|
</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 %}
|
{% endblock %}
|
||||||
|
|
|
@ -1658,7 +1658,8 @@ def inventory_create(request):
|
||||||
'stock_old': article.stock,
|
'stock_old': article.stock,
|
||||||
'name' : article.name,
|
'name' : article.name,
|
||||||
'category' : article.category_id,
|
'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(
|
cls_formset = formset_factory(
|
||||||
|
|
Loading…
Reference in a new issue