mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +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.helpers import GetExportFormats
|
||||||
from InvenTree.forms import HelperForm
|
from InvenTree.forms import HelperForm
|
||||||
|
from InvenTree.fields import RoundingDecimalFormField
|
||||||
|
|
||||||
from .models import StockLocation, StockItem, StockItemTracking, StockItemAttachment
|
from .models import StockLocation, StockItem, StockItemTracking, StockItemAttachment
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ class CreateStockItemForm(HelperForm):
|
|||||||
self._clean_form()
|
self._clean_form()
|
||||||
|
|
||||||
|
|
||||||
class SerializeStockForm(forms.ModelForm):
|
class SerializeStockForm(HelperForm):
|
||||||
""" Form for serializing a StockItem. """
|
""" 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)')
|
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)')
|
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:
|
class Meta:
|
||||||
model = StockItem
|
model = StockItem
|
||||||
|
|
||||||
|
@ -755,7 +755,18 @@ class StockItemSerialize(AjaxUpdateView):
|
|||||||
model = StockItem
|
model = StockItem
|
||||||
ajax_template_name = 'stock/item_serialize.html'
|
ajax_template_name = 'stock/item_serialize.html'
|
||||||
ajax_form_title = _('Serialize Stock')
|
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):
|
def get_initial(self):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user