Use barcode amounts also for Consume/Transfer/Inventory (closes #1254)

This commit is contained in:
Bernd Bestel
2021-01-04 21:59:19 +01:00
parent d78e156609
commit 45abc99a77
4 changed files with 133 additions and 14 deletions

View File

@@ -182,6 +182,41 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
}
}
if (document.getElementById("product_id").getAttribute("barcode") != "null")
{
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
function(barcodeResult)
{
if (barcodeResult != null)
{
var barcode = barcodeResult[0];
if (barcode != null)
{
if (barcode.amount != null && !barcode.amount.isEmpty())
{
$("#display_amount").val(barcode.amount);
$("#display_amount").select();
}
if (barcode.qu_id != null)
{
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
}
$(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('inventory-form');
RefreshLocaleNumberInput();
}
}
},
function(xhr)
{
console.error(xhr);
}
);
}
$('#display_amount').val(productDetails.stock_amount);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");