mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Pass StockItem object through to the SerializeStock form
This commit is contained in:
parent
5b5b848a98
commit
72cfaccac5
@ -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
|
||||
|
||||
|
@ -755,7 +755,18 @@ class StockItemSerialize(AjaxUpdateView):
|
||||
model = StockItem
|
||||
ajax_template_name = 'stock/item_serialize.html'
|
||||
ajax_form_title = _('Serialize Stock')
|
||||
form_class = SerializeStockForm
|
||||
#form_class = SerializeStockForm
|
||||
|
||||
def get_form(self):
|
||||
|
||||
context = self.get_form_kwargs()
|
||||
|
||||
# Pass the StockItem object through to the form
|
||||
context['item'] = self.get_object()
|
||||
|
||||
form = SerializeStockForm(**context)
|
||||
|
||||
return form
|
||||
|
||||
def get_initial(self):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user