Merge pull request #1163 from SchrodingersGat/hide-purchase-price

Hide purchase price field for non-purchaseable parts
This commit is contained in:
Oliver 2020-12-14 10:43:21 +11:00 committed by GitHub
commit 70cac17138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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