mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
[#2885] Support hyphens in serials when correct no of serials supplied
This commit is contained in:
parent
b08efa4de7
commit
82b32fe30e
@ -458,8 +458,18 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
|
||||
if len(serials) == 0:
|
||||
raise ValidationError([_("Empty serial number string")])
|
||||
|
||||
for group in groups:
|
||||
# If the user has supplied the correct number of serials, don't process them for groups
|
||||
# just add them so any duplicates (or future validations) are checked
|
||||
if len(groups) == expected_quantity:
|
||||
for group in groups:
|
||||
add_sn(group)
|
||||
|
||||
if len(errors) > 0:
|
||||
raise ValidationError(errors)
|
||||
|
||||
return numbers
|
||||
|
||||
for group in groups:
|
||||
group = group.strip()
|
||||
|
||||
# Hyphen indicates a range of numbers
|
||||
|
@ -257,6 +257,11 @@ class TestSerialNumberExtraction(TestCase):
|
||||
self.assertEqual(len(sn), 5)
|
||||
self.assertEqual(sn, [1, 2, 4, 5, 6])
|
||||
|
||||
# Test groups are not interpolated if enough serials are supplied
|
||||
sn = e("1, 2, 3, AF5-69H, 5", 5, 1)
|
||||
self.assertEqual(len(sn), 5)
|
||||
self.assertEqual(sn, [1, 2, 3, "AF5-69H", 5])
|
||||
|
||||
# Test groups are not interpolated with more than one hyphen in a word
|
||||
sn = e("1, 2, TG-4SR-92, 4+", 5, 1)
|
||||
self.assertEqual(len(sn), 5)
|
||||
|
Loading…
Reference in New Issue
Block a user