Add lot number to add stock form
This commit is contained in:
		@@ -79,6 +79,7 @@ class AddStockForm(forms.Form):
 | 
				
			|||||||
    watermark = forms.IntegerField(min_value=0, required=True, initial=0)
 | 
					    watermark = forms.IntegerField(min_value=0, required=True, initial=0)
 | 
				
			||||||
    amount = forms.IntegerField(min_value=0, required=True, initial=1)
 | 
					    amount = forms.IntegerField(min_value=0, required=True, initial=1)
 | 
				
			||||||
    component_uuid = forms.UUIDField(required=True)
 | 
					    component_uuid = forms.UUIDField(required=True)
 | 
				
			||||||
 | 
					    lot = forms.CharField(max_length=255, required=False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def clean(self):
 | 
					    def clean(self):
 | 
				
			||||||
        cleaned_data = super().clean()
 | 
					        cleaned_data = super().clean()
 | 
				
			||||||
@@ -103,7 +104,7 @@ class AddStockForm(forms.Form):
 | 
				
			|||||||
        if self.cleaned_data.get('watermark_active'):
 | 
					        if self.cleaned_data.get('watermark_active'):
 | 
				
			||||||
            watermark = self.cleaned_data.get('watermark')
 | 
					            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()
 | 
					        new_stock.save()
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
class EditComponentForm(forms.Form):
 | 
					class EditComponentForm(forms.Form):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,15 @@ Input context:
 | 
				
			|||||||
                        {% endfor %}
 | 
					                        {% endfor %}
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </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">
 | 
					                    <div class="mb-3">
 | 
				
			||||||
                        <label for="add-stock-form-watermark" class="form-label">Watermark</label>
 | 
					                        <label for="add-stock-form-watermark" class="form-label">Watermark</label>
 | 
				
			||||||
                        <div class="input-group">
 | 
					                        <div class="input-group">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,6 +76,9 @@
 | 
				
			|||||||
                            {% if stock.component.manufacturer %}
 | 
					                            {% if stock.component.manufacturer %}
 | 
				
			||||||
                                Manufacturer: {{stock.component.manufacturer}}
 | 
					                                Manufacturer: {{stock.component.manufacturer}}
 | 
				
			||||||
                            {% endif %}
 | 
					                            {% endif %}
 | 
				
			||||||
 | 
					                            {% if stock.lot %}
 | 
				
			||||||
 | 
					                                <span class="text-secondary"><br>Lot: {{stock.lot}}</span>
 | 
				
			||||||
 | 
					                            {% endif %}
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                        <div class="ms-3">
 | 
					                        <div class="ms-3">
 | 
				
			||||||
                            Amount: {{stock.amount}}
 | 
					                            Amount: {{stock.amount}}
 | 
				
			||||||
@@ -92,7 +95,7 @@
 | 
				
			|||||||
                            <form method="post">
 | 
					                            <form method="post">
 | 
				
			||||||
                                {% csrf_token %}
 | 
					                                {% csrf_token %}
 | 
				
			||||||
                                <input type="hidden" name="stock_uuid" value="{{stock.id}}">
 | 
					                                <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>
 | 
					                            </form>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
                    </li>
 | 
					                    </li>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user