Add barcode to existing product update to add to product_barcodes table

This commit is contained in:
Kurt Riddlesperger 2020-04-28 12:12:35 -05:00
parent fa2cd22ac1
commit 982b83c87b
4 changed files with 67 additions and 4 deletions

View File

@ -59,13 +59,28 @@
{ {
$("#flow-info-addbarcodetoselection").addClass("d-none"); $("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none'); $('#barcode-lookup-disabled-hint').addClass('d-none');
window.history.replaceState({ }, document.title, U("/consume"));
}, },
function(xhr) function(xhr)
{ {
console.error(xhr); console.error(xhr);
} }
); );
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
function(result)
{
window.history.replaceState({ }, document.title, U("/consume"));
},
function(xhr)
{
Grocy.FrontendHelpers.EndUiBusy("barcode-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
}
);
} }
$("#specific_stock_entry").find("option").remove().end().append("<option></option>"); $("#specific_stock_entry").find("option").remove().end().append("<option></option>");

View File

@ -52,13 +52,29 @@
{ {
$("#flow-info-addbarcodetoselection").addClass("d-none"); $("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none'); $('#barcode-lookup-disabled-hint').addClass('d-none');
window.history.replaceState({ }, document.title, U("/inventory"));
}, },
function(xhr) function(xhr)
{ {
console.error(xhr); console.error(xhr);
} }
); );
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
function(result)
{
window.history.replaceState({ }, document.title, U("/inventory"));
},
function(xhr)
{
Grocy.FrontendHelpers.EndUiBusy("barcode-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
}
);
} }
Grocy.Api.Get('stock/products/' + jsonForm.product_id, Grocy.Api.Get('stock/products/' + jsonForm.product_id,

View File

@ -65,7 +65,6 @@
{ {
$("#flow-info-addbarcodetoselection").addClass("d-none"); $("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none'); $('#barcode-lookup-disabled-hint').addClass('d-none');
window.history.replaceState({ }, document.title, U("/purchase"));
}, },
function(xhr) function(xhr)
{ {
@ -73,6 +72,24 @@
console.error(xhr); console.error(xhr);
} }
); );
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
jsonDataBarcode.qu_factor_purchase_to_stock = jsonForm.qu_factor_purchase_to_stock;
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
function(result)
{
window.history.replaceState({ }, document.title, U("/purchase"));
},
function(xhr)
{
Grocy.FrontendHelpers.EndUiBusy("barcode-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
}
);
} }
var successMessage = __t('Added %1$s of %2$s to stock', result.amount + " " + __n(result.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>'; var successMessage = __t('Added %1$s of %2$s to stock', result.amount + " " + __n(result.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + result.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';

View File

@ -45,13 +45,28 @@
{ {
$("#flow-info-addbarcodetoselection").addClass("d-none"); $("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none'); $('#barcode-lookup-disabled-hint').addClass('d-none');
window.history.replaceState({ }, document.title, U("/transfer"));
}, },
function(xhr) function(xhr)
{ {
console.error(xhr); console.error(xhr);
} }
); );
var jsonDataBarcode = {};
jsonDataBarcode.barcode = addBarcode;
jsonDataBarcode.product_id = jsonForm.product_id;
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
function(result)
{
window.history.replaceState({ }, document.title, U("/transfer"));
},
function(xhr)
{
Grocy.FrontendHelpers.EndUiBusy("barcode-form");
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
}
);
} }
if (productDetails.product.enable_tare_weight_handling == 1) if (productDetails.product.enable_tare_weight_handling == 1)