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

Add hidden input to the InstallStockForm form

- keeps track of "part" object
- so we can filter the stock_items queryset if the form validation fails
- Is there a more djangonic way of doing this??
This commit is contained in:
Oliver Walters
2020-10-04 23:45:52 +11:00
parent 46f459b4c7
commit 42a75a8238
2 changed files with 24 additions and 6 deletions

View File

@@ -19,6 +19,8 @@ from InvenTree.fields import RoundingDecimalFormField
from report.models import TestReport
from part.models import Part
from .models import StockLocation, StockItem, StockItemTracking
from .models import StockItemAttachment
from .models import StockItemTestResult
@@ -278,6 +280,11 @@ class InstallStockForm(HelperForm):
Form for manually installing a stock item into another stock item
"""
part = forms.ModelChoiceField(
queryset=Part.objects.all(),
widget=forms.HiddenInput
)
stock_item = forms.ModelChoiceField(
required=True,
queryset=StockItem.objects.filter(StockItem.IN_STOCK_FILTER),
@@ -302,6 +309,7 @@ class InstallStockForm(HelperForm):
class Meta:
model = StockItem
fields = [
'part',
'stock_item',
'quantity_to_install',
'notes',