mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Whoops, that form was being used.
Created a copy of the form for multiple-item-stock-movements
This commit is contained in:
parent
56821abd09
commit
3869bc27c9
@ -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')
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user