From 1b19940aba09fa8669d94173b445a589875cc0d7 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 17 Sep 2019 16:01:30 +0200 Subject: [PATCH] Only cascade changes of stock QU to recipe ingredients which uses the same QU (references #177) --- migrations/0082.sql | 9 +++++++++ public/viewjs/recipeposform.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/migrations/0082.sql b/migrations/0082.sql index ed81cd4b..ca473330 100644 --- a/migrations/0082.sql +++ b/migrations/0082.sql @@ -102,3 +102,12 @@ JOIN quantity_units qu_from ON quc.from_qu_id = qu_from.id JOIN quantity_units qu_to ON quc.to_qu_id = qu_to.id; + +DROP TRIGGER cascade_change_qu_id_stock; +CREATE TRIGGER cascade_change_qu_id_stock AFTER UPDATE ON products +BEGIN + UPDATE recipes_pos + SET qu_id = NEW.qu_id_stock + WHERE product_id = NEW.id + AND qu_id = OLD.qu_id_stock; +END; diff --git a/public/viewjs/recipeposform.js b/public/viewjs/recipeposform.js index e6d8ed1e..7b559a34 100644 --- a/public/viewjs/recipeposform.js +++ b/public/viewjs/recipeposform.js @@ -52,7 +52,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) function(productDetails) { Grocy.RecipePosFormProductChangeCount++; - console.log(Grocy.RecipePosFormProductChangeCount); + if (Grocy.RecipePosFormProductChangeCount < 3) // This triggers twice on inital page load, however { Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id, true);