From e494aef1ff669a33539dd387de550b95da274e1f Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 1 Aug 2025 15:34:30 +1000 Subject: [PATCH] Tweak low-stock notification (#10112) - Prevent notification for inactive parts --- src/backend/InvenTree/part/tasks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend/InvenTree/part/tasks.py b/src/backend/InvenTree/part/tasks.py index 9a09d7f98b..a3d85e5cd8 100644 --- a/src/backend/InvenTree/part/tasks.py +++ b/src/backend/InvenTree/part/tasks.py @@ -33,6 +33,10 @@ def notify_low_stock(part: Model): - Triggered when the available stock for a given part falls be low the configured threhsold - A notification is delivered to any users who are 'subscribed' to this part """ + # Do not trigger low-stock notifications for inactive parts + if not part.active: + return + name = _('Low stock notification') message = _( f'The available stock for {part.name} has fallen below the configured minimum level' @@ -146,7 +150,7 @@ def notify_low_stock_if_required(part_id: int): parts = part.get_ancestors(include_self=True, ascending=True) for p in parts: - if p.is_part_low_on_stock(): + if part.active and p.is_part_low_on_stock(): offload_task(notify_low_stock, p, group='notification')