diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js
index 1661b955..cd8a6c3c 100644
--- a/public/viewjs/consume.js
+++ b/public/viewjs/consume.js
@@ -59,13 +59,28 @@
{
$("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none');
- window.history.replaceState({ }, document.title, U("/consume"));
},
function(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("");
diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js
index df4727a5..79b1a805 100644
--- a/public/viewjs/inventory.js
+++ b/public/viewjs/inventory.js
@@ -52,13 +52,29 @@
{
$("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none');
- window.history.replaceState({ }, document.title, U("/inventory"));
},
function(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,
diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js
index 224c6497..e04e5e4d 100644
--- a/public/viewjs/purchase.js
+++ b/public/viewjs/purchase.js
@@ -65,7 +65,6 @@
{
$("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none');
- window.history.replaceState({ }, document.title, U("/purchase"));
},
function(xhr)
{
@@ -73,6 +72,24 @@
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) + '
' + __t("Undo") + '';
diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js
index c803b303..fac54131 100644
--- a/public/viewjs/transfer.js
+++ b/public/viewjs/transfer.js
@@ -45,13 +45,28 @@
{
$("#flow-info-addbarcodetoselection").addClass("d-none");
$('#barcode-lookup-disabled-hint').addClass('d-none');
- window.history.replaceState({ }, document.title, U("/transfer"));
},
function(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)