mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-05 21:20:56 +00:00
Form / view for downloading stocktake info
This commit is contained in:
@ -31,6 +31,7 @@ from .forms import EditStockItemForm
|
||||
from .forms import AdjustStockForm
|
||||
from .forms import TrackingEntryForm
|
||||
from .forms import SerializeStockForm
|
||||
from .forms import ExportOptionsForm
|
||||
|
||||
|
||||
class StockIndex(ListView):
|
||||
@ -119,6 +120,38 @@ class StockLocationQRCode(QRCodeView):
|
||||
return None
|
||||
|
||||
|
||||
class StockExportOptions(AjaxView):
|
||||
""" Form for selecting StockExport options """
|
||||
|
||||
model = StockLocation
|
||||
ajax_form_title = 'Stock Export Options'
|
||||
form_class = ExportOptionsForm
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
||||
self.request = request
|
||||
|
||||
fmt = request.POST.get('file_format', 'csv').lower()
|
||||
cascade = str2bool(request.POST.get('include_sublocations', True))
|
||||
|
||||
# Format a URL to redirect to
|
||||
url = reverse('stock-export')
|
||||
|
||||
url += '?format=' + fmt
|
||||
url += '&cascade=' + str(cascade)
|
||||
|
||||
data = {
|
||||
'form_valid': True,
|
||||
'format': fmt,
|
||||
'cascade': cascade
|
||||
}
|
||||
|
||||
return self.renderJsonResponse(self.request, self.form_class(), data=data)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return self.renderJsonResponse(request, self.form_class())
|
||||
|
||||
|
||||
class StockExport(AjaxView):
|
||||
""" Export stock data from a particular location.
|
||||
Returns a file containing stock information for that location.
|
||||
|
Reference in New Issue
Block a user