diff --git a/InvenTree/common/files.py b/InvenTree/common/files.py index 62f6426ef7..94f96f42e5 100644 --- a/InvenTree/common/files.py +++ b/InvenTree/common/files.py @@ -118,6 +118,12 @@ class FileManager: 'Description', ] + self.OPTIONAL_MATCH_HEADERS = [ + 'Category', + 'default_location', + 'default_supplier', + ] + self.OPTIONAL_HEADERS = [ 'Keywords', 'IPN', diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index 23799e4fec..75ab43ef81 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -42,6 +42,8 @@ from common.models import InvenTreeSetting from company.models import SupplierPart from common.views import FileManagementFormView +from stock.models import StockLocation + import common.settings as inventree_settings from . import forms as part_forms @@ -746,6 +748,9 @@ class PartImport(FileManagementFormView): 'minimum_stock': 'minimum_stock', 'units': 'units', 'notes': 'notes', + 'category': 'category', + 'default_location': 'default_location', + 'default_supplier': 'default_supplier', } def get_field_selection(self): @@ -762,6 +767,14 @@ class PartImport(FileManagementFormView): # fetch available elements self.allowed_items = {} self.matches = {} + + self.allowed_items['Category'] = PartCategory.objects.all() + self.matches['Category'] = ['name__contains'] + self.allowed_items['default_location'] = StockLocation.objects.all() + self.matches['default_location'] = ['name__contains'] + self.allowed_items['default_supplier'] = SupplierPart.objects.all() + self.matches['default_supplier'] = ['SKU__contains'] + for row in self.rows: for idx in idx_s: data = row['data'][idx_s[idx]]['cell'] @@ -833,6 +846,9 @@ class PartImport(FileManagementFormView): minimum_stock=part_data.get('minimum_stock', 0), units=part_data.get('units', None), notes=part_data.get('notes', None), + category=optional_matches['Category'], + default_location=optional_matches['default_location'], + default_supplier=optional_matches['default_supplier'], ) try: new_part.save()