mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Prevent adding "Disable own stock"-products to stock (references #564)
This commit is contained in:
@@ -64,3 +64,13 @@ LEFT JOIN products p_parent
|
|||||||
LEFT JOIN locations l
|
LEFT JOIN locations l
|
||||||
ON p.location_id = l.id
|
ON p.location_id = l.id
|
||||||
WHERE p.hide_on_stock_overview = 0;
|
WHERE p.hide_on_stock_overview = 0;
|
||||||
|
|
||||||
|
CREATE TRIGGER prevent_adding_no_own_stock_products_to_stock AFTER INSERT ON stock
|
||||||
|
BEGIN
|
||||||
|
SELECT CASE WHEN((
|
||||||
|
SELECT 1
|
||||||
|
FROM products p
|
||||||
|
WHERE id = NEW.product_id
|
||||||
|
AND no_own_stock = 1
|
||||||
|
) NOTNULL) THEN RAISE(ABORT, "no_own_stock=1 products can't be added to stock") END;
|
||||||
|
END;
|
||||||
|
Reference in New Issue
Block a user