mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Correctly handle serialization of newly created stock
This commit is contained in:
parent
3be4acf3ef
commit
b41dbba2b0
@ -445,8 +445,14 @@ class StockList(generics.ListCreateAPIView):
|
||||
# Finally, save the item (with user information)
|
||||
item.save(user=user)
|
||||
|
||||
# Serialize the stock, if required
|
||||
if serials:
|
||||
"""
|
||||
Serialize the stock, if required
|
||||
|
||||
- Note that the "original" stock item needs to be created first, so it can be serialized
|
||||
- It is then immediately deleted
|
||||
"""
|
||||
|
||||
try:
|
||||
item.serializeStock(
|
||||
quantity,
|
||||
@ -455,6 +461,19 @@ class StockList(generics.ListCreateAPIView):
|
||||
notes=notes,
|
||||
location=item.location,
|
||||
)
|
||||
|
||||
headers = self.get_success_headers(serializer.data)
|
||||
|
||||
# Delete the original item
|
||||
item.delete()
|
||||
|
||||
response_data = {
|
||||
'quantity': quantity,
|
||||
'serial_numbers': serials,
|
||||
}
|
||||
|
||||
return Response(response_data, status=status.HTTP_201_CREATED, headers=headers)
|
||||
|
||||
except DjangoValidationError as e:
|
||||
raise ValidationError({
|
||||
'quantity': e.messages,
|
||||
|
@ -115,6 +115,10 @@ function canDelete(OPTIONS) {
|
||||
*/
|
||||
function getApiEndpointOptions(url, callback) {
|
||||
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Return the ajax request object
|
||||
$.ajax({
|
||||
url: url,
|
||||
@ -727,6 +731,8 @@ function submitFormData(fields, options) {
|
||||
break;
|
||||
default:
|
||||
$(options.modal).modal('hide');
|
||||
|
||||
console.log(`upload error at ${options.url}`);
|
||||
showApiError(xhr, options.url);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user