Add lot number to add stock form

This commit is contained in:
2021-12-31 14:03:25 +01:00
parent e959f11051
commit ca61437110
3 changed files with 15 additions and 2 deletions

View File

@@ -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):