diff --git a/changelog/76_UNRELEASED_xxxx-xx-xx.md b/changelog/76_UNRELEASED_xxxx-xx-xx.md index d345ac0a..271abab4 100644 --- a/changelog/76_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/76_UNRELEASED_xxxx-xx-xx.md @@ -16,7 +16,7 @@ - After that, the transaction is continued with that product - Fixed that when copying a product, the field "Treat opened as out of stock" wasn't copied along (thanks @TheDodger) - Fixed that the product groups filter on the master data products page used a contains search instead of an exact search -- Fixed that Scan Mode on the purchase page didn't work (not all fields were properly populated) when using/scanning a product Grocycodes +- Fixed that Scan Mode on the purchase and consume page didn't work (not all fields were properly populated) when using/scanning a product Grocycodes ### Shopping list diff --git a/grocy.openapi.json b/grocy.openapi.json index 03b0051d..4781a2b8 100644 --- a/grocy.openapi.json +++ b/grocy.openapi.json @@ -5905,7 +5905,8 @@ "products_average_price", "quantity_unit_conversions_resolved", "recipes_pos_resolved", - "battery_charge_cycles" + "battery_charge_cycles", + "product_barcodes_view" ] }, "ExposedEntityNoListing": { @@ -5926,7 +5927,8 @@ "products_average_price", "quantity_unit_conversions_resolved", "recipes_pos_resolved", - "battery_charge_cycles" + "battery_charge_cycles", + "product_barcodes_view" ] }, "ExposedEntityNoDelete": { @@ -5940,7 +5942,8 @@ "products_average_price", "quantity_unit_conversions_resolved", "recipes_pos_resolved", - "battery_charge_cycles" + "battery_charge_cycles", + "product_barcodes_view" ] }, "ExposedEntityEditRequiresAdmin": { diff --git a/migrations/0238.sql b/migrations/0238.sql new file mode 100644 index 00000000..a305181d --- /dev/null +++ b/migrations/0238.sql @@ -0,0 +1,26 @@ +CREATE VIEW product_barcodes_view +AS +SELECT + pb.id, + pb.product_id, + pb.barcode, + pb.qu_id, + pb.amount, + pb.shopping_location_id, + pb.last_price, + pb.note +FROM product_barcodes pb + +UNION ALL + +-- Product Grocycodes +SELECT + p.id, + p.id AS product_id, + 'grcy:p:' || CAST(p.id AS TEXT) AS barcode, + p.qu_id_stock AS qu_id, + NULL AS amount, + NULL AS shopping_location_id, + NULL AS last_price, + NULL AS note +FROM products p; diff --git a/public/viewjs/components/productpicker.js b/public/viewjs/components/productpicker.js index f6371792..94cac3aa 100644 --- a/public/viewjs/components/productpicker.js +++ b/public/viewjs/components/productpicker.js @@ -170,6 +170,7 @@ $('#product_id_text_input').on('blur', function(e) { possibleOptionElement = $("#product_id option[value=\"" + gc[2] + "\"]").first(); $("#product_id").data("grocycode", true); + $('#product_id').attr("barcode", input); } } else // Normal product barcode handling @@ -298,7 +299,7 @@ $('#product_id_text_input').on('blur', function(e) // otherwise an error validation message that the product is not in stock var existsAsProduct = false; var existsAsBarcode = false; - Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + input, + Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + input, function(barcodeResult) { if (barcodeResult.length > 0) diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 0146e5e7..2fab1da7 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -257,6 +257,10 @@ $("#location_id").on('change', function(e) } ); } + else + { + OnLocationChange(locationId, null); + } } else { @@ -326,7 +330,7 @@ function OnLocationChange(locationId, stockId) } ); - if (document.getElementById("product_id").getAttribute("barcode") == "null") + if (document.getElementById("product_id").getAttribute("barcode") == "null" || $("#product_id").data("grocycode")) { ScanModeSubmit(); } diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js index c7f57e80..50a4cd79 100644 --- a/public/viewjs/inventory.js +++ b/public/viewjs/inventory.js @@ -270,7 +270,7 @@ 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"), + Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"), function(barcodeResult) { if (barcodeResult) diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index 4d518d3c..7489b76d 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -355,7 +355,7 @@ if (Grocy.Components.ProductPicker !== undefined) if (document.getElementById("product_id").getAttribute("barcode") != "null") { - Grocy.Api.Get('objects/product_barcodes?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"), + Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"), function(barcodeResult) { if (barcodeResult && barcodeResult.length > 0) diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js index 183edd83..ba998794 100644 --- a/public/viewjs/transfer.js +++ b/public/viewjs/transfer.js @@ -213,7 +213,7 @@ 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"), + Grocy.Api.Get('objects/product_barcodes_view?query[]=barcode=' + document.getElementById("product_id").getAttribute("barcode"), function(barcodeResult) { if (barcodeResult != null)