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

Beginning to move the stocktake forms server side

This commit is contained in:
Oliver Walters
2019-05-29 22:05:13 +10:00
parent da4f68e5a5
commit 2b4cb4d3e0
4 changed files with 57 additions and 0 deletions

View File

@@ -45,13 +45,34 @@ class CreateStockItemForm(HelperForm):
class MoveStockItemForm(forms.ModelForm):
""" Form for moving a StockItem to a new location """
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
location = forms.ChoiceField(label='Destination', required=True, help_text='Destination stock location')
note = forms.CharField(label='Notes', required=True, help_text='Add note (required)')
transaction = forms.BooleanField(required=False, initial=False, label='Create Transaction', help_text='Create a stock transaction for these parts')
confirm = forms.BooleanField(required=False, initial=False, label='Confirm Stock Movement', help_text='Confirm movement of stock items')
def __init__(self, *args, **kwargs):
super(MoveStockItemForm, self).__init__(*args, **kwargs)
self.fields['location'].choices = self.get_location_choices()
class Meta:
model = StockItem
fields = [
'location',
'note',
'transaction',
'confirm',
]