mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +00:00
Filter available stock items by Part reference
This commit is contained in:
parent
f04977e7e1
commit
fd22e713ff
@ -283,8 +283,10 @@ class InstallStockForm(HelperForm):
|
|||||||
help_text=_('Stock item to install')
|
help_text=_('Stock item to install')
|
||||||
)
|
)
|
||||||
|
|
||||||
quantity = RoundingDecimalFormField(
|
quantity_to_install = RoundingDecimalFormField(
|
||||||
max_digits=10, decimal_places=5,
|
max_digits=10, decimal_places=5,
|
||||||
|
initial=1,
|
||||||
|
label=_('Quantity'),
|
||||||
help_text=_('Stock quantity to assign'),
|
help_text=_('Stock quantity to assign'),
|
||||||
validators=[
|
validators=[
|
||||||
MinValueValidator(0.001)
|
MinValueValidator(0.001)
|
||||||
@ -295,7 +297,7 @@ class InstallStockForm(HelperForm):
|
|||||||
model = StockItem
|
model = StockItem
|
||||||
fields = [
|
fields = [
|
||||||
'stock_item',
|
'stock_item',
|
||||||
'quantity',
|
'quantity_to_install',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -703,6 +703,22 @@ class StockItemInstall(AjaxUpdateView):
|
|||||||
|
|
||||||
form = super().get_form()
|
form = super().get_form()
|
||||||
|
|
||||||
|
queryset = form.fields['stock_item'].queryset
|
||||||
|
|
||||||
|
part = self.request.GET.get('part', None)
|
||||||
|
|
||||||
|
# Filter the available stock items based on the Part reference
|
||||||
|
if part:
|
||||||
|
try:
|
||||||
|
part = Part.objects.get(pk=part)
|
||||||
|
|
||||||
|
queryset = queryset.filter(part=part)
|
||||||
|
|
||||||
|
except (ValueError, Part.DoesNotExist):
|
||||||
|
pass
|
||||||
|
|
||||||
|
form.fields['stock_item'].queryset = queryset
|
||||||
|
|
||||||
return form
|
return form
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user