mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Optimized product Grocycode handling on consume page (and others / general) (fixes #2571)
This commit is contained in:
parent
1246f402e5
commit
d5dacb1053
@ -16,7 +16,7 @@
|
|||||||
- After that, the transaction is continued with that product
|
- 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 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 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
|
### Shopping list
|
||||||
|
|
||||||
|
@ -5905,7 +5905,8 @@
|
|||||||
"products_average_price",
|
"products_average_price",
|
||||||
"quantity_unit_conversions_resolved",
|
"quantity_unit_conversions_resolved",
|
||||||
"recipes_pos_resolved",
|
"recipes_pos_resolved",
|
||||||
"battery_charge_cycles"
|
"battery_charge_cycles",
|
||||||
|
"product_barcodes_view"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ExposedEntityNoListing": {
|
"ExposedEntityNoListing": {
|
||||||
@ -5926,7 +5927,8 @@
|
|||||||
"products_average_price",
|
"products_average_price",
|
||||||
"quantity_unit_conversions_resolved",
|
"quantity_unit_conversions_resolved",
|
||||||
"recipes_pos_resolved",
|
"recipes_pos_resolved",
|
||||||
"battery_charge_cycles"
|
"battery_charge_cycles",
|
||||||
|
"product_barcodes_view"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ExposedEntityNoDelete": {
|
"ExposedEntityNoDelete": {
|
||||||
@ -5940,7 +5942,8 @@
|
|||||||
"products_average_price",
|
"products_average_price",
|
||||||
"quantity_unit_conversions_resolved",
|
"quantity_unit_conversions_resolved",
|
||||||
"recipes_pos_resolved",
|
"recipes_pos_resolved",
|
||||||
"battery_charge_cycles"
|
"battery_charge_cycles",
|
||||||
|
"product_barcodes_view"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ExposedEntityEditRequiresAdmin": {
|
"ExposedEntityEditRequiresAdmin": {
|
||||||
|
26
migrations/0238.sql
Normal file
26
migrations/0238.sql
Normal file
@ -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;
|
@ -170,6 +170,7 @@ $('#product_id_text_input').on('blur', function(e)
|
|||||||
{
|
{
|
||||||
possibleOptionElement = $("#product_id option[value=\"" + gc[2] + "\"]").first();
|
possibleOptionElement = $("#product_id option[value=\"" + gc[2] + "\"]").first();
|
||||||
$("#product_id").data("grocycode", true);
|
$("#product_id").data("grocycode", true);
|
||||||
|
$('#product_id').attr("barcode", input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Normal product barcode handling
|
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
|
// otherwise an error validation message that the product is not in stock
|
||||||
var existsAsProduct = false;
|
var existsAsProduct = false;
|
||||||
var existsAsBarcode = 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)
|
function(barcodeResult)
|
||||||
{
|
{
|
||||||
if (barcodeResult.length > 0)
|
if (barcodeResult.length > 0)
|
||||||
|
@ -257,6 +257,10 @@ $("#location_id").on('change', function(e)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnLocationChange(locationId, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
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();
|
ScanModeSubmit();
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
|
|
||||||
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
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)
|
function(barcodeResult)
|
||||||
{
|
{
|
||||||
if (barcodeResult)
|
if (barcodeResult)
|
||||||
|
@ -355,7 +355,7 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||||||
|
|
||||||
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
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)
|
function(barcodeResult)
|
||||||
{
|
{
|
||||||
if (barcodeResult && barcodeResult.length > 0)
|
if (barcodeResult && barcodeResult.length > 0)
|
||||||
|
@ -213,7 +213,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
|
|
||||||
if (document.getElementById("product_id").getAttribute("barcode") != "null")
|
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)
|
function(barcodeResult)
|
||||||
{
|
{
|
||||||
if (barcodeResult != null)
|
if (barcodeResult != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user