mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Fix code to move multiple parts via AJAX / JSON
This commit is contained in:
parent
757cd539b2
commit
990808ec03
@ -149,9 +149,7 @@ function updateStock(items, options={}) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
closeModal(modal);
|
closeModal(modal);
|
||||||
if (options.success) {
|
afterForm(response, options);
|
||||||
options.success();
|
|
||||||
}
|
|
||||||
}).fail(function(xhr, status, error) {
|
}).fail(function(xhr, status, error) {
|
||||||
alert(error);
|
alert(error);
|
||||||
});
|
});
|
||||||
@ -233,27 +231,20 @@ function moveStockItems(items, options) {
|
|||||||
'notes': notes,
|
'notes': notes,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
success: function(response) {
|
method: 'post',
|
||||||
|
}).then(function(response) {
|
||||||
closeModal(modal);
|
closeModal(modal);
|
||||||
if (options.success) {
|
afterForm(response, options);
|
||||||
options.success();
|
}).fail(function(xhr, status, error) {
|
||||||
}
|
alert(error);
|
||||||
},
|
|
||||||
error: function(error) {
|
|
||||||
alert('error!:\n' + error);
|
|
||||||
},
|
|
||||||
method: 'post'
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getStockLocations({},
|
getStockLocations({},
|
||||||
{
|
{
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
openModal({
|
|
||||||
modal: modal,
|
|
||||||
title: "Move " + items.length + " stock items",
|
|
||||||
submit_text: "Move"
|
|
||||||
});
|
|
||||||
|
|
||||||
// Extact part row info
|
// Extact part row info
|
||||||
var parts = [];
|
var parts = [];
|
||||||
@ -290,7 +281,14 @@ function moveStockItems(items, options) {
|
|||||||
|
|
||||||
html += "</ul>\n";
|
html += "</ul>\n";
|
||||||
|
|
||||||
modalSetContent(modal, html);
|
openModal({
|
||||||
|
modal: modal,
|
||||||
|
title: "Move " + items.length + " stock items",
|
||||||
|
submit_text: "Move",
|
||||||
|
content: html
|
||||||
|
});
|
||||||
|
|
||||||
|
//modalSetContent(modal, html);
|
||||||
attachSelect(modal);
|
attachSelect(modal);
|
||||||
|
|
||||||
$(modal).find('#note-warning').hide();
|
$(modal).find('#note-warning').hide();
|
||||||
|
@ -166,12 +166,15 @@ class StockMove(APIView):
|
|||||||
if len(errors) > 0:
|
if len(errors) > 0:
|
||||||
raise ValidationError(errors)
|
raise ValidationError(errors)
|
||||||
|
|
||||||
|
n = 0
|
||||||
|
|
||||||
for part in parts:
|
for part in parts:
|
||||||
part.move(location, data.get('notes'), request.user)
|
if part.move(location, data.get('notes'), request.user):
|
||||||
|
n += 1
|
||||||
|
|
||||||
return Response({'success': 'Moved {n} parts to {loc}'.format(
|
return Response({'success': 'Moved {n} parts to {loc}'.format(
|
||||||
n=len(parts),
|
n=n,
|
||||||
loc=location.name
|
loc=str(location)
|
||||||
)})
|
)})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user