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

@@ -192,6 +192,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('transfer-form');
RefreshLocaleNumberInput();
}
}
},
function(xhr)
{
console.error(xhr);
}
);
}
if (productDetails.product.enable_tare_weight_handling == 1)
{
$("#display_amount").attr("min", productDetails.product.tare_weight);