Hide purchase price field for non-purchaseable parts

This commit is contained in:
Oliver Walters 2020-12-14 09:55:39 +11:00
parent 1c168452a4
commit 648595cf18

View File

@ -1292,6 +1292,7 @@ class StockItemEdit(AjaxUpdateView):
# If the part cannot be purchased, hide the supplier_part field # If the part cannot be purchased, hide the supplier_part field
if not item.part.purchaseable: if not item.part.purchaseable:
form.fields['supplier_part'].widget = HiddenInput() form.fields['supplier_part'].widget = HiddenInput()
form.fields['purchase_price'].widget = HiddenInput()
else: else:
query = form.fields['supplier_part'].queryset query = form.fields['supplier_part'].queryset
query = query.filter(part=item.part.id) query = query.filter(part=item.part.id)
@ -1505,6 +1506,9 @@ class StockItemCreate(AjaxCreateView):
form.rebuild_layout() form.rebuild_layout()
if not part.purchaseable:
form.fields['purchase_price'].widget = HiddenInput()
# Hide the 'part' field (as a valid part is selected) # Hide the 'part' field (as a valid part is selected)
# form.fields['part'].widget = HiddenInput() # form.fields['part'].widget = HiddenInput()