mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-07 04:12:11 +00:00
Tweak low-stock notification (#10112)
- Prevent notification for inactive parts
This commit is contained in:
@@ -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
|
- 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
|
- 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')
|
name = _('Low stock notification')
|
||||||
message = _(
|
message = _(
|
||||||
f'The available stock for {part.name} has fallen below the configured minimum level'
|
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)
|
parts = part.get_ancestors(include_self=True, ascending=True)
|
||||||
|
|
||||||
for p in parts:
|
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')
|
offload_task(notify_low_stock, p, group='notification')
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user