Whoops, that form was being used.

Created a copy of the form for multiple-item-stock-movements
This commit is contained in:
Oliver Walters 2019-05-30 09:01:16 +10:00
parent 56821abd09
commit 3869bc27c9
2 changed files with 35 additions and 3 deletions

View File

@ -198,7 +198,7 @@ class InvenTreeTree(models.Model):
def __str__(self):
""" String representation of a category is the full path to that category """
return self.pathstring
return "{path} - {desc}".format(path=self.pathstring, desc=self.description)
@receiver(pre_delete, sender=InvenTreeTree, dispatch_uid='tree_pre_delete_log')

View File

@ -42,9 +42,21 @@ class CreateStockItemForm(HelperForm):
]
class MoveStockItemForm(forms.ModelForm):
class MoveStockItemForm(HelperForm):
""" Form for moving a StockItem to a new location """
note = forms.CharField(label='Notes', required=True, help_text='Add note (required)')
class Meta:
model = StockItem
fields = [
'location',
'note'
]
class MoveMultipleStockItemsForm(forms.ModelForm):
def get_location_choices(self):
locs = StockLocation.objects.all()
@ -68,7 +80,27 @@ class MoveStockItemForm(forms.ModelForm):
self.fields['location'].choices = self.get_location_choices()
for item in stock_items:
self.fields['stock_item_{id}'.format(id=item.id)] = forms.IntegerField(required=True, initial=item.quantity, help_text='Quantity for ' + str(item))
field = forms.IntegerField(
label= str(item.part),
required=True,
initial=item.quantity,
help_text='Quantity for ' + str(item))
extra = {
'name': str(item.part),
'location': str(item.location),
'quantity': str(item.quantity),
}
field.extra = extra
self.fields['stock_item_{id}'.format(id=item.id)] = field
def get_stock_fields(self):
for field_name in self.fields:
if field_name.startswith('stock_item_'):
print(field_name, self[field_name], self[field_name].extra)
yield self[field_name]
class Meta:
model = StockItem