2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-19 13:35:40 +00:00

Add optional part lookup by "part" field

This commit is contained in:
Oliver
2022-02-07 08:37:39 +11:00
parent 81271bf6b9
commit 0963602bea
2 changed files with 12 additions and 4 deletions

View File

@ -883,6 +883,16 @@ class BomExtractSerializer(serializers.Serializer):
except (ValueError, Part.DoesNotExist):
pass
# Optionally, specify using field "part"
if part is None:
pk = self.find_matching_data(row, 'part', headers)
if pk is not None:
try:
part = Part.objects.get(pk=pk)
except (ValueError, Part.DoesNotExist):
pass
if part is None:
if part_name is not None or part_ipn is not None:
@ -900,8 +910,6 @@ class BomExtractSerializer(serializers.Serializer):
row['part'] = part.pk if part is not None else None
print("part:", part)
rows.append(row)
return {