From ad57ca5ddfff2a4e4da17dbde4dcf97b644e85e7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 27 Jun 2022 07:30:38 +1000 Subject: [PATCH] Adds notification when items are received against a purcahse order (#3259) --- InvenTree/common/notifications.py | 7 +++++++ InvenTree/order/models.py | 9 +++++++++ .../templates/email/purchase_order_received.html | 11 +++++++++++ 3 files changed, 27 insertions(+) create mode 100644 InvenTree/templates/email/purchase_order_received.html diff --git a/InvenTree/common/notifications.py b/InvenTree/common/notifications.py index bfd125afc1..6122f181c7 100644 --- a/InvenTree/common/notifications.py +++ b/InvenTree/common/notifications.py @@ -296,6 +296,13 @@ class InvenTreeNotificationBodies: ) """Send when a new order (build, sale or purchase) was created.""" + ItemsReceived = NotificationBody( + name=_("Items Received"), + slug='purchase_order.items_received', + message=_('Items have been received against a purchase order'), + template='email/purchase_order_received.html', + ) + def trigger_notification(obj, category=None, obj_ref='pk', **kwargs): """Send out a notification.""" diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 2f82d6af95..3f4274fb95 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -24,6 +24,7 @@ from mptt.models import TreeForeignKey import InvenTree.helpers import InvenTree.ready +from common.notifications import InvenTreeNotificationBodies from common.settings import currency_code_default from company.models import Company, SupplierPart from InvenTree.exceptions import log_error @@ -560,6 +561,14 @@ class PurchaseOrder(Order): self.received_by = user self.complete_order() # This will save the model + # Issue a notification to interested parties, that this order has been "updated" + notify_responsible( + self, + PurchaseOrder, + exclude=user, + content=InvenTreeNotificationBodies.ItemsReceived, + ) + @receiver(post_save, sender=PurchaseOrder, dispatch_uid='purchase_order_post_save') def after_save_purchase_order(sender, instance: PurchaseOrder, created: bool, **kwargs): diff --git a/InvenTree/templates/email/purchase_order_received.html b/InvenTree/templates/email/purchase_order_received.html new file mode 100644 index 0000000000..46ff982e90 --- /dev/null +++ b/InvenTree/templates/email/purchase_order_received.html @@ -0,0 +1,11 @@ +{% extends "email/email.html" %} + +{% load i18n %} +{% load inventree_extras %} + +{% block title %} +{{ message }} +{% if link %} +

{% trans "Click on the following link to view this order" %}: {{ link }}

+{% endif %} +{% endblock title %}