mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 13:28:49 +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)
|
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'):
|
def DownloadFile(data, filename, content_type='application/text'):
|
||||||
""" Create a dynamic file for the user to download.
|
""" 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.forms.utils import ErrorDict
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
from InvenTree.helpers import GetExportFormats
|
||||||
from InvenTree.forms import HelperForm
|
from InvenTree.forms import HelperForm
|
||||||
from .models import StockLocation, StockItem, StockItemTracking
|
from .models import StockLocation, StockItem, StockItemTracking
|
||||||
|
|
||||||
@ -113,11 +114,7 @@ class ExportOptionsForm(HelperForm):
|
|||||||
def get_format_choices(self):
|
def get_format_choices(self):
|
||||||
""" File format choices """
|
""" File format choices """
|
||||||
|
|
||||||
choices = [
|
choices = [(x, x.upper()) for x in GetExportFormats()]
|
||||||
('csv', 'CSV'),
|
|
||||||
('xls', 'XLS'),
|
|
||||||
('xlsx', 'XLSX'),
|
|
||||||
]
|
|
||||||
|
|
||||||
return choices
|
return choices
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
$("#location-export").click(function() {
|
$("#location-export").click(function() {
|
||||||
launchModalForm("{% url 'stock-export-options' %}",
|
launchModalForm("{% url 'stock-export-options' %}",
|
||||||
{
|
{
|
||||||
|
submit_text: "Export",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
var url = "{% url 'stock-export' %}";
|
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 AjaxUpdateView, AjaxDeleteView, AjaxCreateView
|
||||||
from InvenTree.views import QRCodeView
|
from InvenTree.views import QRCodeView
|
||||||
|
|
||||||
from InvenTree.helpers import str2bool, DownloadFile
|
from InvenTree.helpers import str2bool, DownloadFile, GetExportFormats
|
||||||
from InvenTree.helpers import ExtractSerialNumbers
|
from InvenTree.helpers import ExtractSerialNumbers
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ class StockExport(AjaxView):
|
|||||||
location = None
|
location = None
|
||||||
|
|
||||||
|
|
||||||
if export_format not in ['csv', 'xls', 'xslx']:
|
if export_format not in GetExportFormats():
|
||||||
export_format = 'csv'
|
export_format = 'csv'
|
||||||
|
|
||||||
filename = 'InvenTree_Stocktake_{loc}_{date}.{fmt}'.format(
|
filename = 'InvenTree_Stocktake_{loc}_{date}.{fmt}'.format(
|
||||||
@ -203,6 +203,8 @@ class StockExport(AjaxView):
|
|||||||
_('Part ID'),
|
_('Part ID'),
|
||||||
_('Part'),
|
_('Part'),
|
||||||
_('Supplier Part ID'),
|
_('Supplier Part ID'),
|
||||||
|
_('Supplier ID'),
|
||||||
|
_('Supplier'),
|
||||||
_('Location ID'),
|
_('Location ID'),
|
||||||
_('Location'),
|
_('Location'),
|
||||||
_('Quantity'),
|
_('Quantity'),
|
||||||
@ -228,8 +230,12 @@ class StockExport(AjaxView):
|
|||||||
|
|
||||||
if item.supplier_part:
|
if item.supplier_part:
|
||||||
line.append(item.supplier_part.pk)
|
line.append(item.supplier_part.pk)
|
||||||
|
line.append(item.supplier_part.supplier.pk)
|
||||||
|
line.append(item.supplier_part.supplier.name)
|
||||||
else:
|
else:
|
||||||
line.append('')
|
line.append('')
|
||||||
|
line.append('')
|
||||||
|
line.append('')
|
||||||
|
|
||||||
line.append(item.location.pk)
|
line.append(item.location.pk)
|
||||||
line.append(item.location.name)
|
line.append(item.location.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user