mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-01 03:00:54 +00:00
Add ability to edit / assign attatched files to test result data
This commit is contained in:
@ -46,6 +46,7 @@ class EditStockItemTestResultForm(HelperForm):
|
||||
'test',
|
||||
'result',
|
||||
'value',
|
||||
'attachment',
|
||||
'notes',
|
||||
]
|
||||
|
||||
|
@ -261,6 +261,17 @@ 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
|
||||
|
||||
|
||||
@ -278,6 +289,8 @@ 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