diff --git a/src/backend/InvenTree/InvenTree/helpers_model.py b/src/backend/InvenTree/InvenTree/helpers_model.py index 455c8e000d42..8bbaad6912ac 100644 --- a/src/backend/InvenTree/InvenTree/helpers_model.py +++ b/src/backend/InvenTree/InvenTree/helpers_model.py @@ -363,6 +363,7 @@ def notify_responsible( instance, sender, content: NotificationBody = InvenTreeNotificationBodies.NewOrder, + html_context: Optional[dict] = None, exclude=None, extra_users: Optional[list] = None, ): @@ -375,6 +376,7 @@ def notify_responsible( instance: The newly created instance sender: Sender model reference content (NotificationBody, optional): _description_. Defaults to InvenTreeNotificationBodies.NewOrder. + html_context: Optional HTML context to include in the notification. Defaults to None. exclude (User, optional): User instance that should be excluded. Defaults to None. extra_users (list, optional): List of extra users to notify. Defaults to None. """ @@ -388,7 +390,14 @@ def notify_responsible( if extra_users: users.extend(extra_users) - notify_users(users, instance, sender, content=content, exclude=exclude) + notify_users( + users, + instance, + sender, + content=content, + html_context=html_context, + exclude=exclude, + ) def notify_users( @@ -396,6 +405,7 @@ def notify_users( instance, sender, content: NotificationBody = InvenTreeNotificationBodies.NewOrder, + html_context: Optional[dict] = None, exclude=None, ): """Notify all passed users or groups. @@ -408,6 +418,7 @@ def notify_users( instance: The newly created instance sender: Sender model reference content (NotificationBody, optional): _description_. Defaults to InvenTreeNotificationBodies.NewOrder. + html_context (dict, optional): Optional HTML context to include in the notification. Defaults to None. exclude (User, optional): User instance that should be excluded. Defaults to None. """ # Setup context for notification parsing @@ -427,9 +438,11 @@ def notify_users( 'template': {'subject': content.name.format(**content_context)}, } - tmp = content.template - if tmp: - context['template']['html'] = tmp.format(**content_context) + if tmp := content.template: + html_context = html_context or {} + html_context.update(content_context) + + context['template']['html'] = tmp.format(**html_context) # Create notification trigger_notification( diff --git a/src/backend/InvenTree/order/models.py b/src/backend/InvenTree/order/models.py index 58a67ef1f35f..777c533375c1 100644 --- a/src/backend/InvenTree/order/models.py +++ b/src/backend/InvenTree/order/models.py @@ -1227,6 +1227,7 @@ def receive_line_items( exclude=user, content=InvenTreeNotificationBodies.ItemsReceived, extra_users=line.part.part.get_subscribers(), + html_context={'order': self, 'stock_items': stock_items}, ) # Return a list of the created stock items diff --git a/src/backend/InvenTree/templates/email/purchase_order_received.html b/src/backend/InvenTree/templates/email/purchase_order_received.html index 46ff982e9073..39deaab06e1f 100644 --- a/src/backend/InvenTree/templates/email/purchase_order_received.html +++ b/src/backend/InvenTree/templates/email/purchase_order_received.html @@ -9,3 +9,18 @@
{% trans "Click on the following link to view this order" %}: {{ link }}
{% endif %} {% endblock title %} + +{% block body %} +