2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-04 20:51:00 +00:00

Automagically disable 'serial_numbers' field for StockItemCreate form

- Yay, ajax magic!
This commit is contained in:
Oliver Walters
2020-10-20 22:37:55 +11:00
parent 2e4613e702
commit 652c2dbcbe
3 changed files with 18 additions and 6 deletions

View File

@ -1510,11 +1510,8 @@ class StockItemCreate(AjaxCreateView):
# form.fields['part'].widget = HiddenInput()
# Trackable parts get special consideration:
if part.trackable:
form.fields['delete_on_deplete'].widget = HiddenInput()
form.fields['delete_on_deplete'].initial = False
else:
form.fields['serial_numbers'].widget = HiddenInput()
form.fields['delete_on_deplete'].disabled = not part.trackable
form.fields['serial_numbers'].disabled = not part.trackable
# If the part is NOT purchaseable, hide the supplier_part field
if not part.purchaseable:
@ -1539,6 +1536,8 @@ class StockItemCreate(AjaxCreateView):
# We must not provide *any* options for SupplierPart
form.fields['supplier_part'].queryset = SupplierPart.objects.none()
form.fields['serial_numbers'].disabled = True
# Otherwise if the user has selected a SupplierPart, we know what Part they meant!
if form['supplier_part'].value() is not None:
pass