2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-16 01:08:12 +00:00

Add form / view for serializing a stock item

- Back end doesn't do anything yet
This commit is contained in:
Oliver Walters
2019-08-28 21:46:26 +10:00
parent 3b8f5872ac
commit 7575a39b7f
5 changed files with 76 additions and 4 deletions

View File

@@ -63,6 +63,39 @@ class CreateStockItemForm(HelperForm):
self._clean_form()
class SerializeStockForm(forms.ModelForm):
""" Form for serializing a StockItem. """
destination = forms.ChoiceField(label='Destination', required=True, help_text='Destination for serialized stock (by default, will remain in current location)')
serial_numbers = forms.CharField(label='Serial numbers', required=True, help_text='Unique serial numbers')
note = forms.CharField(label='Notes', required=False, help_text='Add transaction note')
def get_location_choices(self):
locs = StockLocation.objects.all()
choices = [(None, '---------')]
for loc in locs:
choices.append((loc.pk, loc.pathstring + ' - ' + loc.description))
return choices
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['destination'].choices = self.get_location_choices()
class Meta:
model = StockItem
fields = [
'quantity',
'serial_numbers',
'destination',
'note',
]
class AdjustStockForm(forms.ModelForm):
""" Form for performing simple stock adjustments.