From 5ae62410834228df8338bd150d5aeb8bf9cecd07 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 4 Nov 2021 16:15:11 +1100 Subject: [PATCH 1/4] Fixes for low-stock emails - Include variant stock in test - Improve email template --- InvenTree/part/models.py | 2 +- InvenTree/templates/email/low_stock_notification.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index f37b61864d..9dd4031886 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2098,7 +2098,7 @@ class Part(MPTTModel): Returns True if the total stock for this part is less than the minimum stock level """ - return self.total_stock <= self.minimum_stock + return self.get_stock_count() <= self.minimum_stock @receiver(post_save, sender=Part, dispatch_uid='part_post_save_log') diff --git a/InvenTree/templates/email/low_stock_notification.html b/InvenTree/templates/email/low_stock_notification.html index 4db9c2ddaa..7b52ebc0cd 100644 --- a/InvenTree/templates/email/low_stock_notification.html +++ b/InvenTree/templates/email/low_stock_notification.html @@ -24,8 +24,8 @@ {{ part.full_name }} - {{ part.total_stock }} - {{ part.available_stock }} - {{ part.minimum_stock }} + {% decimal part.total_stock %} + {% part.available_stock %} + {% part.minimum_stock %} {% endblock %} From 75d7530e30dfc731771f739417db204f9d0bb5fa Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 4 Nov 2021 16:17:05 +1100 Subject: [PATCH 2/4] Fix missing tag in template --- InvenTree/templates/email/low_stock_notification.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/templates/email/low_stock_notification.html b/InvenTree/templates/email/low_stock_notification.html index 7b52ebc0cd..bc0a82fd23 100644 --- a/InvenTree/templates/email/low_stock_notification.html +++ b/InvenTree/templates/email/low_stock_notification.html @@ -25,7 +25,7 @@ {{ part.full_name }} {% decimal part.total_stock %} - {% part.available_stock %} - {% part.minimum_stock %} + {% decimal part.available_stock %} + {% decimal part.minimum_stock %} {% endblock %} From 3a7f8c91966152378b984ff621360260eb110cf0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 4 Nov 2021 16:18:49 +1100 Subject: [PATCH 3/4] Fix comparison operator --- InvenTree/part/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 9dd4031886..23aea29dbd 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2098,7 +2098,7 @@ class Part(MPTTModel): Returns True if the total stock for this part is less than the minimum stock level """ - return self.get_stock_count() <= self.minimum_stock + return self.get_stock_count() < self.minimum_stock @receiver(post_save, sender=Part, dispatch_uid='part_post_save_log') From 39d3a127e1abc1ff47bd6f7074383bd97bef469c Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 4 Nov 2021 16:19:57 +1100 Subject: [PATCH 4/4] Template improvements --- .../templates/email/low_stock_notification.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/InvenTree/templates/email/low_stock_notification.html b/InvenTree/templates/email/low_stock_notification.html index bc0a82fd23..f922187f33 100644 --- a/InvenTree/templates/email/low_stock_notification.html +++ b/InvenTree/templates/email/low_stock_notification.html @@ -8,15 +8,12 @@ {% if link %}

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

{% endif %} -{% endblock %} +{% endblock title %} -{% block subtitle %} -

{% blocktrans with part=part.name %}You are receiving this email because you are subscribed to notifications for this part {% endblocktrans %}.

-{% endblock %} {% block body %} - {% trans "Part Name" %} + {% trans "Part" %} {% trans "Total Stock" %} {% trans "Available" %} {% trans "Minimum Quantity" %} @@ -28,4 +25,8 @@ {% decimal part.available_stock %} {% decimal part.minimum_stock %} -{% endblock %} +{% endblock body %} + +{% block footer_prefix %} +

{% blocktrans with part=part.name %}You are receiving this email because you are subscribed to notifications for this part {% endblocktrans %}.

+{% endblock footer_prefix %}