From 2af617e92bd005b650fd8a4efccce41434cec69f Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 9 Feb 2022 11:34:25 +1100 Subject: [PATCH] Adds check for duplicate parts when importing --- InvenTree/part/serializers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 308641085a..aef0c1ee0f 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -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