Adds notification when items are received against a purcahse order (#3259)

This commit is contained in:
Oliver 2022-06-27 07:30:38 +10:00 committed by GitHub
parent b13e12b7bd
commit ad57ca5ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 0 deletions

View File

@ -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."""

View File

@ -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):

View File

@ -0,0 +1,11 @@
{% extends "email/email.html" %}
{% load i18n %}
{% load inventree_extras %}
{% block title %}
{{ message }}
{% if link %}
<p>{% trans "Click on the following link to view this order" %}: <a href='{{ link }}'>{{ link }}</a></p>
{% endif %}
{% endblock title %}