mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 21:45:39 +00:00
Added post_delete hook to StockItem
moved the business logic of 'deciding if a low stock notification has to be sent' to part.tasks
This commit is contained in:
@ -37,3 +37,16 @@ def notify_low_stock(part: Part):
|
||||
html_message = render_to_string('stock/low_stock_notification.html', context)
|
||||
recipients = starred_users_email.values_list('email', flat=True)
|
||||
inventree_tasks.send_email(subject, '', recipients, html_message=html_message)
|
||||
|
||||
|
||||
def notify_low_stock_if_required(part: Part):
|
||||
"""
|
||||
Check if the stock quantity has fallen below the minimum threshold of part. If yes, notify the users who have
|
||||
starred the part
|
||||
"""
|
||||
|
||||
if part.is_part_low_on_stock():
|
||||
inventree_tasks.offload_task(
|
||||
'part.tasks.notify_low_stock',
|
||||
part
|
||||
)
|
||||
|
Reference in New Issue
Block a user