mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Adds check for duplicate parts when importing
This commit is contained in:
parent
67a9c0aeec
commit
2af617e92b
@ -870,6 +870,8 @@ class BomExtractSerializer(serializers.Serializer):
|
||||
rows = []
|
||||
errors = []
|
||||
|
||||
found_parts = set()
|
||||
|
||||
headers = self.dataset.headers
|
||||
|
||||
level_column = self.find_matching_column('level', headers)
|
||||
@ -939,8 +941,14 @@ class BomExtractSerializer(serializers.Serializer):
|
||||
# Multiple matches!
|
||||
error['part'] = _('Multiple matching parts found')
|
||||
|
||||
if part is None and 'part' not in error:
|
||||
error['part'] = _('No matching part found')
|
||||
if part is None:
|
||||
if 'part' not in error:
|
||||
error['part'] = _('No matching part found')
|
||||
else:
|
||||
if part.pk in found_parts:
|
||||
error['part'] = _('Duplicate part selected')
|
||||
else:
|
||||
found_parts.add(part.pk)
|
||||
|
||||
row['part'] = part.pk if part is not None else None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user