mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add supplier information to exported data
This commit is contained in:
parent
cc452bc270
commit
9212d6047f
@ -94,6 +94,18 @@ def MakeBarcode(object_type, object_id, object_url, data={}):
|
||||
return json.dumps(data, sort_keys=True)
|
||||
|
||||
|
||||
def GetExportFormats():
|
||||
""" Return a list of allowable file formats for exporting data """
|
||||
|
||||
return [
|
||||
'csv',
|
||||
'tsv',
|
||||
'xls',
|
||||
'xlsx',
|
||||
'json',
|
||||
]
|
||||
|
||||
|
||||
def DownloadFile(data, filename, content_type='application/text'):
|
||||
""" Create a dynamic file for the user to download.
|
||||
|
||||
|
@ -9,6 +9,7 @@ from django import forms
|
||||
from django.forms.utils import ErrorDict
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from InvenTree.helpers import GetExportFormats
|
||||
from InvenTree.forms import HelperForm
|
||||
from .models import StockLocation, StockItem, StockItemTracking
|
||||
|
||||
@ -113,11 +114,7 @@ class ExportOptionsForm(HelperForm):
|
||||
def get_format_choices(self):
|
||||
""" File format choices """
|
||||
|
||||
choices = [
|
||||
('csv', 'CSV'),
|
||||
('xls', 'XLS'),
|
||||
('xlsx', 'XLSX'),
|
||||
]
|
||||
choices = [(x, x.upper()) for x in GetExportFormats()]
|
||||
|
||||
return choices
|
||||
|
||||
|
@ -73,6 +73,7 @@
|
||||
$("#location-export").click(function() {
|
||||
launchModalForm("{% url 'stock-export-options' %}",
|
||||
{
|
||||
submit_text: "Export",
|
||||
success: function(response) {
|
||||
var url = "{% url 'stock-export' %}";
|
||||
|
||||
|
@ -18,7 +18,7 @@ from InvenTree.views import AjaxView
|
||||
from InvenTree.views import AjaxUpdateView, AjaxDeleteView, AjaxCreateView
|
||||
from InvenTree.views import QRCodeView
|
||||
|
||||
from InvenTree.helpers import str2bool, DownloadFile
|
||||
from InvenTree.helpers import str2bool, DownloadFile, GetExportFormats
|
||||
from InvenTree.helpers import ExtractSerialNumbers
|
||||
from datetime import datetime
|
||||
|
||||
@ -177,7 +177,7 @@ class StockExport(AjaxView):
|
||||
location = None
|
||||
|
||||
|
||||
if export_format not in ['csv', 'xls', 'xslx']:
|
||||
if export_format not in GetExportFormats():
|
||||
export_format = 'csv'
|
||||
|
||||
filename = 'InvenTree_Stocktake_{loc}_{date}.{fmt}'.format(
|
||||
@ -203,6 +203,8 @@ class StockExport(AjaxView):
|
||||
_('Part ID'),
|
||||
_('Part'),
|
||||
_('Supplier Part ID'),
|
||||
_('Supplier ID'),
|
||||
_('Supplier'),
|
||||
_('Location ID'),
|
||||
_('Location'),
|
||||
_('Quantity'),
|
||||
@ -228,8 +230,12 @@ class StockExport(AjaxView):
|
||||
|
||||
if item.supplier_part:
|
||||
line.append(item.supplier_part.pk)
|
||||
line.append(item.supplier_part.supplier.pk)
|
||||
line.append(item.supplier_part.supplier.name)
|
||||
else:
|
||||
line.append('')
|
||||
line.append('')
|
||||
line.append('')
|
||||
|
||||
line.append(item.location.pk)
|
||||
line.append(item.location.name)
|
||||
|
Loading…
Reference in New Issue
Block a user