forked from DGNum/gestioCOF
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(),
|
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">
|
||||||
<thead>
|
<table class="table text-center">
|
||||||
<tr>
|
<thead>
|
||||||
<td>Article</td>
|
|
||||||
<td>Théo.</td>
|
|
||||||
<td>Réel</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{% for form in formset %}
|
|
||||||
{% ifchanged form.category %}
|
|
||||||
<tr>
|
<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>
|
</tr>
|
||||||
{% endifchanged %}
|
</thead>
|
||||||
<tr>
|
<tbody>
|
||||||
{{ form.article }}
|
{% for form in formset %}
|
||||||
<td>{{ form.name }}</td>
|
{% ifchanged form.category %}
|
||||||
<td>{{ form.stock_old }}</td>
|
<tr class='section'>
|
||||||
<td>{{ form.stock_new }}</td>
|
<td>{{ form.category_name }}</td>
|
||||||
</tr>
|
<td colspan="6"></td>
|
||||||
{% endfor %}
|
</tr>
|
||||||
</tbody>
|
{% endifchanged %}
|
||||||
</table>
|
<tr>
|
||||||
{% if not perms.kfet.add_inventory %}
|
{{ form.article }}
|
||||||
<input type="password" name="KFETPASSWORD">
|
<td>{{ form.name }}</td>
|
||||||
{% endif %}
|
<td id='id_{{form.prefix}}-box_capacity'>{{ form.box_capacity }}</td>
|
||||||
{% csrf_token %}
|
<td>{{ form.stock_old }}</td>
|
||||||
{{ formset.management_form }}
|
<td>
|
||||||
<input type="submit" value="Enregistrer" class="btn btn-primary btn-lg">
|
<div class='col-md-2'></div>
|
||||||
</form>
|
<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 %}
|
{% 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