2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-05-23 09:35:30 +00:00

append information about next serial numbe to fnc call

Fixes #2484
This commit is contained in:
Matthias
2021-12-29 03:01:52 +01:00
parent 1d0aa900e8
commit 2ec41b02f8
5 changed files with 20 additions and 18 deletions
+13 -12
View File
@@ -466,18 +466,6 @@ class StockList(generics.ListCreateAPIView):
notes = data.get('notes', '')
serials = None
if serial_numbers:
# If serial numbers are specified, check that they match!
try:
serials = extract_serial_numbers(serial_numbers, quantity)
except DjangoValidationError as e:
raise ValidationError({
'quantity': e.messages,
'serial_numbers': e.messages,
})
with transaction.atomic():
# Create an initial stock item
@@ -493,6 +481,19 @@ class StockList(generics.ListCreateAPIView):
if item.part.default_expiry > 0:
item.expiry_date = datetime.now().date() + timedelta(days=item.part.default_expiry)
# fetch serial numbers
serials = None
if serial_numbers:
# If serial numbers are specified, check that they match!
try:
serials = extract_serial_numbers(serial_numbers, quantity, item.part.getLatestSerialNumberInt())
except DjangoValidationError as e:
raise ValidationError({
'quantity': e.messages,
'serial_numbers': e.messages,
})
# Finally, save the item (with user information)
item.save(user=user)