mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
better group handeling
This commit is contained in:
parent
410c190ddf
commit
ed09d5015a
@ -11,6 +11,7 @@ from PIL import Image
|
|||||||
from decimal import Decimal, InvalidOperation
|
from decimal import Decimal, InvalidOperation
|
||||||
|
|
||||||
from wsgiref.util import FileWrapper
|
from wsgiref.util import FileWrapper
|
||||||
|
from django.db.models.expressions import RawSQL
|
||||||
from django.http import StreamingHttpResponse
|
from django.http import StreamingHttpResponse
|
||||||
from django.core.exceptions import ValidationError, FieldError
|
from django.core.exceptions import ValidationError, FieldError
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -500,12 +501,20 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
|
|||||||
errors.append(_("Invalid group: {g}").format(g=group))
|
errors.append(_("Invalid group: {g}").format(g=group))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Group is a number
|
# Group should be a number
|
||||||
|
elif group:
|
||||||
|
# try conversion
|
||||||
|
try:
|
||||||
|
number = int(group)
|
||||||
|
except:
|
||||||
|
# seem like it is not a number
|
||||||
|
raise ValidationError(_(f"Invalid group {group}"))
|
||||||
|
|
||||||
|
number_add(number)
|
||||||
|
|
||||||
|
# No valid input group detected
|
||||||
else:
|
else:
|
||||||
if group in numbers:
|
raise ValidationError(_(f"Invalid/no group {group}"))
|
||||||
errors.append(_("Duplicate serial: {g}".format(g=group)))
|
|
||||||
else:
|
|
||||||
numbers.append(int(group))
|
|
||||||
|
|
||||||
if len(errors) > 0:
|
if len(errors) > 0:
|
||||||
raise ValidationError(errors)
|
raise ValidationError(errors)
|
||||||
|
Loading…
Reference in New Issue
Block a user