mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
Handle case where a new stock item is to be created without the part being specified
This commit is contained in:
parent
598ddaace9
commit
a116c3f191
@ -136,11 +136,16 @@ class StockItemCreate(AjaxCreateView):
|
|||||||
form = super(AjaxCreateView, self).get_form()
|
form = super(AjaxCreateView, self).get_form()
|
||||||
|
|
||||||
# If the user has selected a Part, limit choices for SupplierPart
|
# If the user has selected a Part, limit choices for SupplierPart
|
||||||
if form['part'].value() is not None:
|
if form['part'].value():
|
||||||
part = form['part'].value()
|
part_id = form['part'].value()
|
||||||
parts = form.fields['supplier_part'].queryset
|
|
||||||
parts = parts.filter(part=part)
|
try:
|
||||||
form.fields['supplier_part'].queryset = parts
|
part = Part.objects.get(id=part_id)
|
||||||
|
parts = form.fields['supplier_part'].queryset
|
||||||
|
parts = parts.filter(part=part.id)
|
||||||
|
form.fields['supplier_part'].queryset = parts
|
||||||
|
except Part.DoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
# Hide the 'part' field
|
# Hide the 'part' field
|
||||||
form.fields['part'].widget = HiddenInput()
|
form.fields['part'].widget = HiddenInput()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user