From cb775061119145d4a6230cadc7ad3fa4e07e9325 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 17 Sep 2019 20:19:05 +1000 Subject: [PATCH] Simplify --- InvenTree/stock/forms.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/InvenTree/stock/forms.py b/InvenTree/stock/forms.py index 1cacd6648b..8145a17f89 100644 --- a/InvenTree/stock/forms.py +++ b/InvenTree/stock/forms.py @@ -69,25 +69,12 @@ class CreateStockItemForm(HelperForm): 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)') + destination = TreeNodeChoiceField(queryset=StockLocation.objects.all(), 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 (must match quantity)') + note = forms.CharField(label='Notes', required=False, help_text='Add transaction note (optional)') - 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