mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Hide supplier_part field if the part cannot be purchased
This commit is contained in:
parent
8bf09300bb
commit
2c5bb6b126
@ -143,6 +143,10 @@ class StockItemEdit(AjaxUpdateView):
|
||||
|
||||
item = self.get_object()
|
||||
|
||||
# If the part cannot be purchased, hide the supplier_part field
|
||||
if not item.part.purchaseable:
|
||||
form.fields['supplier_part'].widget = HiddenInput()
|
||||
else:
|
||||
query = form.fields['supplier_part'].queryset
|
||||
query = query.filter(part=item.part.id)
|
||||
form.fields['supplier_part'].queryset = query
|
||||
@ -206,6 +210,11 @@ class StockItemCreate(AjaxCreateView):
|
||||
part = Part.objects.get(id=part_id)
|
||||
parts = form.fields['supplier_part'].queryset
|
||||
parts = parts.filter(part=part.id)
|
||||
|
||||
# If the part is NOT purchaseable, hide the supplier_part field
|
||||
if not part.purchaseable:
|
||||
form.fields['supplier_part'].widget = HiddenInput()
|
||||
|
||||
form.fields['supplier_part'].queryset = parts
|
||||
|
||||
# If there is one (and only one) supplier part available, pre-select it
|
||||
|
Loading…
Reference in New Issue
Block a user