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

Pass StockItem object through to the SerializeStock form

This commit is contained in:
Oliver Walters
2020-05-15 21:16:00 +10:00
parent 5b5b848a98
commit 72cfaccac5
2 changed files with 26 additions and 2 deletions

View File

@@ -13,6 +13,8 @@ from mptt.fields import TreeNodeChoiceField
from InvenTree.helpers import GetExportFormats
from InvenTree.forms import HelperForm
from InvenTree.fields import RoundingDecimalFormField
from .models import StockLocation, StockItem, StockItemTracking, StockItemAttachment
@@ -79,7 +81,7 @@ class CreateStockItemForm(HelperForm):
self._clean_form()
class SerializeStockForm(forms.ModelForm):
class SerializeStockForm(HelperForm):
""" Form for serializing a StockItem. """
destination = TreeNodeChoiceField(queryset=StockLocation.objects.all(), label='Destination', required=True, help_text='Destination for serialized stock (by default, will remain in current location)')
@@ -88,6 +90,17 @@ class SerializeStockForm(forms.ModelForm):
note = forms.CharField(label='Notes', required=False, help_text='Add transaction note (optional)')
quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
def __init__(self, *args, **kwargs):
# Extract the stock item
stock_item = kwargs.pop('item')
super().__init__(*args, **kwargs)
# TODO - Pre-fill the serial numbers!
class Meta:
model = StockItem