mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
parent
1d0aa900e8
commit
2ec41b02f8
@ -109,7 +109,7 @@ class BuildOutputCreate(AjaxUpdateView):
|
|||||||
# Check that the serial numbers are valid
|
# Check that the serial numbers are valid
|
||||||
if serials:
|
if serials:
|
||||||
try:
|
try:
|
||||||
extracted = extract_serial_numbers(serials, quantity)
|
extracted = extract_serial_numbers(serials, quantity, build.part.getLatestSerialNumberInt())
|
||||||
|
|
||||||
if extracted:
|
if extracted:
|
||||||
# Check for conflicting serial numbers
|
# Check for conflicting serial numbers
|
||||||
@ -143,7 +143,7 @@ class BuildOutputCreate(AjaxUpdateView):
|
|||||||
serials = data.get('serial_numbers', None)
|
serials = data.get('serial_numbers', None)
|
||||||
|
|
||||||
if serials:
|
if serials:
|
||||||
serial_numbers = extract_serial_numbers(serials, quantity)
|
serial_numbers = extract_serial_numbers(serials, quantity, build.part.getLatestSerialNumberInt())
|
||||||
else:
|
else:
|
||||||
serial_numbers = None
|
serial_numbers = None
|
||||||
|
|
||||||
|
@ -861,7 +861,7 @@ class SOSerialAllocationSerializer(serializers.Serializer):
|
|||||||
part = line_item.part
|
part = line_item.part
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data['serials'] = extract_serial_numbers(serial_numbers, quantity)
|
data['serials'] = extract_serial_numbers(serial_numbers, quantity, part.getLatestSerialNumberInt())
|
||||||
except DjangoValidationError as e:
|
except DjangoValidationError as e:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'serial_numbers': e.messages,
|
'serial_numbers': e.messages,
|
||||||
|
@ -466,18 +466,6 @@ class StockList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
notes = data.get('notes', '')
|
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():
|
with transaction.atomic():
|
||||||
|
|
||||||
# Create an initial stock item
|
# Create an initial stock item
|
||||||
@ -493,6 +481,19 @@ class StockList(generics.ListCreateAPIView):
|
|||||||
if item.part.default_expiry > 0:
|
if item.part.default_expiry > 0:
|
||||||
item.expiry_date = datetime.now().date() + timedelta(days=item.part.default_expiry)
|
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)
|
# Finally, save the item (with user information)
|
||||||
item.save(user=user)
|
item.save(user=user)
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ class SerializeStockItemSerializer(serializers.Serializer):
|
|||||||
serial_numbers = data['serial_numbers']
|
serial_numbers = data['serial_numbers']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
serials = InvenTree.helpers.extract_serial_numbers(serial_numbers, quantity)
|
serials = InvenTree.helpers.extract_serial_numbers(serial_numbers, quantity, item.part.getLatestSerialNumberInt())
|
||||||
except DjangoValidationError as e:
|
except DjangoValidationError as e:
|
||||||
raise ValidationError({
|
raise ValidationError({
|
||||||
'serial_numbers': e.messages,
|
'serial_numbers': e.messages,
|
||||||
@ -379,6 +379,7 @@ class SerializeStockItemSerializer(serializers.Serializer):
|
|||||||
serials = InvenTree.helpers.extract_serial_numbers(
|
serials = InvenTree.helpers.extract_serial_numbers(
|
||||||
data['serial_numbers'],
|
data['serial_numbers'],
|
||||||
data['quantity'],
|
data['quantity'],
|
||||||
|
item.part.getLatestSerialNumberInt()
|
||||||
)
|
)
|
||||||
|
|
||||||
item.serializeStock(
|
item.serializeStock(
|
||||||
|
@ -1241,7 +1241,7 @@ class StockItemCreate(AjaxCreateView):
|
|||||||
|
|
||||||
if len(sn) > 0:
|
if len(sn) > 0:
|
||||||
try:
|
try:
|
||||||
serials = extract_serial_numbers(sn, quantity)
|
serials = extract_serial_numbers(sn, quantity, part.getLatestSerialNumberInt())
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
serials = None
|
serials = None
|
||||||
form.add_error('serial_numbers', e.messages)
|
form.add_error('serial_numbers', e.messages)
|
||||||
@ -1283,7 +1283,7 @@ class StockItemCreate(AjaxCreateView):
|
|||||||
|
|
||||||
# Create a single stock item for each provided serial number
|
# Create a single stock item for each provided serial number
|
||||||
if len(sn) > 0:
|
if len(sn) > 0:
|
||||||
serials = extract_serial_numbers(sn, quantity)
|
serials = extract_serial_numbers(sn, quantity, part.getLatestSerialNumberInt())
|
||||||
|
|
||||||
for serial in serials:
|
for serial in serials:
|
||||||
item = StockItem(
|
item = StockItem(
|
||||||
|
Loading…
Reference in New Issue
Block a user