mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-04 20:51:00 +00:00
Improve / simplify logic for file attachments against test result object
This commit is contained in:
@ -292,17 +292,6 @@ class StockItemTestResultCreate(AjaxCreateView):
|
||||
form = super().get_form()
|
||||
form.fields['stock_item'].widget = HiddenInput()
|
||||
|
||||
# Extract the StockItem object
|
||||
item_id = form['stock_item'].value()
|
||||
|
||||
# Limit the options for the file attachments
|
||||
try:
|
||||
stock_item = StockItem.objects.get(pk=item_id)
|
||||
form.fields['attachment'].queryset = stock_item.attachments.all()
|
||||
except (ValueError, StockItem.DoesNotExist):
|
||||
# Hide the attachments field
|
||||
form.fields['attachment'].widget = HiddenInput()
|
||||
|
||||
return form
|
||||
|
||||
|
||||
@ -320,8 +309,6 @@ class StockItemTestResultEdit(AjaxUpdateView):
|
||||
form = super().get_form()
|
||||
|
||||
form.fields['stock_item'].widget = HiddenInput()
|
||||
|
||||
form.fields['attachment'].queryset = self.object.stock_item.attachments.all()
|
||||
|
||||
return form
|
||||
|
||||
|
Reference in New Issue
Block a user