mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Prefill barcode note on /purchase and /inventory (closes #2193)
This commit is contained in:
@@ -272,23 +272,28 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
function(barcodeResult)
|
||||
{
|
||||
if (barcodeResult != null)
|
||||
if (barcodeResult)
|
||||
{
|
||||
var barcode = barcodeResult[0];
|
||||
|
||||
if (barcode != null)
|
||||
if (barcode)
|
||||
{
|
||||
if (barcode.amount != null)
|
||||
if (barcode.amount)
|
||||
{
|
||||
$("#display_amount").val(barcode.amount);
|
||||
$("#display_amount").select();
|
||||
}
|
||||
|
||||
if (barcode.qu_id != null)
|
||||
if (barcode.qu_id)
|
||||
{
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
|
||||
}
|
||||
|
||||
if (barcode.note)
|
||||
{
|
||||
$("#note").val(barcode.note);
|
||||
}
|
||||
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||
RefreshLocaleNumberInput();
|
||||
|
@@ -357,20 +357,20 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"),
|
||||
function(barcodeResult)
|
||||
{
|
||||
if (barcodeResult != null)
|
||||
if (barcodeResult)
|
||||
{
|
||||
var barcode = barcodeResult[0];
|
||||
$("#purchase-form").attr("data-used-barcode", barcode.id);
|
||||
|
||||
if (barcode != null)
|
||||
if (barcode)
|
||||
{
|
||||
if (barcode.amount != null)
|
||||
if (barcode.amount)
|
||||
{
|
||||
$("#display_amount").val(barcode.amount);
|
||||
$("#display_amount").select();
|
||||
}
|
||||
|
||||
if (barcode.qu_id != null)
|
||||
if (barcode.qu_id)
|
||||
{
|
||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(barcode.qu_id);
|
||||
}
|
||||
@@ -386,6 +386,11 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
$("#price-type-total-price").click();
|
||||
}
|
||||
|
||||
if (barcode.note)
|
||||
{
|
||||
$("#note").val(barcode.note);
|
||||
}
|
||||
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
||||
RefreshLocaleNumberInput();
|
||||
|
Reference in New Issue
Block a user