Add lot number to add stock form
This commit is contained in:
parent
e959f11051
commit
ca61437110
@ -79,6 +79,7 @@ class AddStockForm(forms.Form):
|
||||
watermark = forms.IntegerField(min_value=0, required=True, initial=0)
|
||||
amount = forms.IntegerField(min_value=0, required=True, initial=1)
|
||||
component_uuid = forms.UUIDField(required=True)
|
||||
lot = forms.CharField(max_length=255, required=False)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
@ -103,7 +104,7 @@ class AddStockForm(forms.Form):
|
||||
if self.cleaned_data.get('watermark_active'):
|
||||
watermark = self.cleaned_data.get('watermark')
|
||||
|
||||
new_stock = parts_models.Stock.objects.create(storage=storage, component=component, watermark=watermark, amount=amount)
|
||||
new_stock = parts_models.Stock.objects.create(storage=storage, component=component, watermark=watermark, amount=amount, lot=self.cleaned_data['lot'])
|
||||
new_stock.save()
|
||||
|
||||
class EditComponentForm(forms.Form):
|
||||
|
@ -33,6 +33,15 @@ Input context:
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="add-stock-form-lot" class="form-label">Lot</label>
|
||||
<input type="text" name="{{form.lot.html_name}}" id="add-stock-form-lot" class="form-control{% if form.lot.errors %} is-invalid{% endif %}" aria-describedby="add-stock-form-lot-err">
|
||||
<div id="add-stock-form-lot-err" class="invalid-feedback">
|
||||
{% for msg in form.lot.errors %}
|
||||
{{msg}}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="add-stock-form-watermark" class="form-label">Watermark</label>
|
||||
<div class="input-group">
|
||||
|
@ -76,6 +76,9 @@
|
||||
{% if stock.component.manufacturer %}
|
||||
Manufacturer: {{stock.component.manufacturer}}
|
||||
{% endif %}
|
||||
{% if stock.lot %}
|
||||
<span class="text-secondary"><br>Lot: {{stock.lot}}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="ms-3">
|
||||
Amount: {{stock.amount}}
|
||||
@ -92,7 +95,7 @@
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="stock_uuid" value="{{stock.id}}">
|
||||
<input type="submit" class="btn btn-danger" name="submit-delete-stock" value="X">
|
||||
<input type="submit" class="btn btn-danger m-1" name="submit-delete-stock" value="X">
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user