From d8796f95356730784b31ddd078c618780e3c3918 Mon Sep 17 00:00:00 2001 From: rocheparadox Date: Fri, 29 Oct 2021 16:03:41 +0530 Subject: [PATCH 01/33] Notify users who have starred a part when that part's stock quantity falls below the minimum quanitity/threshold through email. --- InvenTree/InvenTree/tasks.py | 36 +++++++++++++++++-- InvenTree/stock/models.py | 14 +++++++- .../stock/low_stock_notification.html | 27 ++++++++++++++ 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 InvenTree/stock/templates/stock/low_stock_notification.html diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index aa17ef8603..9987a2593d 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -11,6 +11,7 @@ from django.utils import timezone from django.core.exceptions import AppRegistryNotReady from django.db.utils import OperationalError, ProgrammingError +from django.template.loader import render_to_string logger = logging.getLogger("inventree") @@ -52,7 +53,7 @@ def schedule_task(taskname, **kwargs): pass -def offload_task(taskname, force_sync=False, *args, **kwargs): +def offload_task(taskname, *args, force_sync=False, **kwargs): """ Create an AsyncTask if workers are running. This is different to a 'scheduled' task, @@ -290,7 +291,7 @@ def update_exchange_rates(): Rate.objects.filter(backend="InvenTreeExchange").exclude(currency__in=currency_codes()).delete() -def send_email(subject, body, recipients, from_email=None): +def send_email(subject, body, recipients, from_email=None, html_message=None): """ Send an email with the specified subject and body, to the specified recipients list. @@ -306,4 +307,35 @@ def send_email(subject, body, recipients, from_email=None): from_email, recipients, fail_silently=False, + html_message=html_message ) + + +def notify_low_stock(stock_item): + """ + Notify users who have starred a part when its stock quantity falls below the minimum threshold + """ + + from allauth.account.models import EmailAddress + starred_users = EmailAddress.objects.filter(user__starred_parts__part=stock_item.part) + + if len(starred_users) > 0: + logger.info(f"Notify users regarding low stock of {stock_item.part.name}") + body = f'Hi, {stock_item.part.name} is low on stock. Kindly do the needful.' + context = { + 'part_name': stock_item.part.name, + # Part url can be used to open the page of part in application from the email. + # It can be facilitated when the application base url is accessible programmatically. + # 'part_url': f'{application_base_url}/part/{stock_item.part.id}', + + 'message': body, + + # quantity is in decimal field datatype. Since the same datatype is used in models, + # it is not converted to number/integer, + 'part_quantity': stock_item.quantity, + 'minimum_quantity': stock_item.part.minimum_stock + } + subject = f'Attention! {stock_item.part.name} is low on stock' + html_message = render_to_string('stock/low_stock_notification.html', context) + recipients = starred_users.values_list('email', flat=True) + send_email(subject, body, recipients, html_message=html_message) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 1372e63406..ff8b91b105 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -17,7 +17,7 @@ from django.db.models import Sum, Q from django.db.models.functions import Coalesce from django.core.validators import MinValueValidator from django.contrib.auth.models import User -from django.db.models.signals import pre_delete +from django.db.models.signals import pre_delete, post_save from django.dispatch import receiver from markdownx.models import MarkdownxField @@ -36,6 +36,7 @@ import label.models from InvenTree.status_codes import StockStatus, StockHistoryCode from InvenTree.models import InvenTreeTree, InvenTreeAttachment from InvenTree.fields import InvenTreeModelMoneyField, InvenTreeURLField +from InvenTree import tasks as inventree_tasks from users.models import Owner @@ -1651,6 +1652,17 @@ def before_delete_stock_item(sender, instance, using, **kwargs): child.save() +@receiver(post_save, sender=StockItem) +def after_save_stock_item(sender, instance: StockItem, **kwargs): + """ + Check if the stock quantity has fallen below the minimum threshold of part. If yes, notify the users who have + starred the part + """ + + if instance.quantity <= instance.part.minimum_stock: + inventree_tasks.notify_low_stock(instance) + + class StockItemAttachment(InvenTreeAttachment): """ Model for storing file attachments against a StockItem object. diff --git a/InvenTree/stock/templates/stock/low_stock_notification.html b/InvenTree/stock/templates/stock/low_stock_notification.html new file mode 100644 index 0000000000..fa3799f6dd --- /dev/null +++ b/InvenTree/stock/templates/stock/low_stock_notification.html @@ -0,0 +1,27 @@ +

{{ message }}

+ + + + + + + + + + + + + + + + + + + + + + + +
Part low on stock
Part NameAvailable QuantityMinimum Quantity
{{ part_name }}{{ part_quantity }}{{ minimum_quantity }}
You are receiving this mail because you have starred the part {{ part_name }} in + Inventree application
+ From 83309fd054f0aa9cfab16e57a23a7eeecb4468e8 Mon Sep 17 00:00:00 2001 From: rocheparadox Date: Sat, 30 Oct 2021 08:16:42 +0530 Subject: [PATCH 02/33] Fixed the order of fixtures installation for testing --- InvenTree/InvenTree/test_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/test_api.py b/InvenTree/InvenTree/test_api.py index dfe94c034e..6ace21b576 100644 --- a/InvenTree/InvenTree/test_api.py +++ b/InvenTree/InvenTree/test_api.py @@ -102,9 +102,9 @@ class APITests(InvenTreeAPITestCase): fixtures = [ 'location', - 'stock', - 'part', 'category', + 'part', + 'stock' ] token = None From e0cd02ee60a5ea42cd2735d4700a8ab34d9af950 Mon Sep 17 00:00:00 2001 From: rocheparadox Date: Sat, 30 Oct 2021 08:30:39 +0530 Subject: [PATCH 03/33] added dispatch_uid to post_save signal of StockItem --- InvenTree/stock/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index ff8b91b105..b4746e0879 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -1652,7 +1652,7 @@ def before_delete_stock_item(sender, instance, using, **kwargs): child.save() -@receiver(post_save, sender=StockItem) +@receiver(post_save, sender=StockItem, dispatch_uid='stock_item_post_save_log') def after_save_stock_item(sender, instance: StockItem, **kwargs): """ Check if the stock quantity has fallen below the minimum threshold of part. If yes, notify the users who have From 6ec2801fcea15d0784e0ad57f6000e8b568aa05b Mon Sep 17 00:00:00 2001 From: rocheparadox Date: Sat, 30 Oct 2021 20:32:10 +0530 Subject: [PATCH 04/33] Facilitated translation for low stock notification subject moved the message/content of low stock notification to html template Facilitated translation in low stock notification html template file --- InvenTree/InvenTree/tasks.py | 8 +++----- .../stock/templates/stock/low_stock_notification.html | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index 9987a2593d..da1d29d76a 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -12,6 +12,7 @@ from django.utils import timezone from django.core.exceptions import AppRegistryNotReady from django.db.utils import OperationalError, ProgrammingError from django.template.loader import render_to_string +from django.utils.translation import gettext_lazy as _ logger = logging.getLogger("inventree") @@ -321,21 +322,18 @@ def notify_low_stock(stock_item): if len(starred_users) > 0: logger.info(f"Notify users regarding low stock of {stock_item.part.name}") - body = f'Hi, {stock_item.part.name} is low on stock. Kindly do the needful.' context = { 'part_name': stock_item.part.name, # Part url can be used to open the page of part in application from the email. # It can be facilitated when the application base url is accessible programmatically. # 'part_url': f'{application_base_url}/part/{stock_item.part.id}', - 'message': body, - # quantity is in decimal field datatype. Since the same datatype is used in models, # it is not converted to number/integer, 'part_quantity': stock_item.quantity, 'minimum_quantity': stock_item.part.minimum_stock } - subject = f'Attention! {stock_item.part.name} is low on stock' + subject = _(f'Attention! {stock_item.part.name} is low on stock') html_message = render_to_string('stock/low_stock_notification.html', context) recipients = starred_users.values_list('email', flat=True) - send_email(subject, body, recipients, html_message=html_message) + send_email(subject, '', recipients, html_message=html_message) diff --git a/InvenTree/stock/templates/stock/low_stock_notification.html b/InvenTree/stock/templates/stock/low_stock_notification.html index fa3799f6dd..04ada64e18 100644 --- a/InvenTree/stock/templates/stock/low_stock_notification.html +++ b/InvenTree/stock/templates/stock/low_stock_notification.html @@ -1,4 +1,6 @@ -

{{ message }}

+{% load i18n %} + +

{% trans "Hi, " %} {{ part_name }} {% trans "is low on stock. Kindly do the needful." %}

@@ -19,8 +21,9 @@ - +
You are receiving this mail because you have starred the part {{ part_name }} in - Inventree application{% trans "You are receiving this mail because you have starred the part " %} {{ part_name }} + {% trans "Inventree application" %} +
From fca15a0439969181cfbafc3c93799f7e329df4ad Mon Sep 17 00:00:00 2001 From: rocheparadox Date: Sun, 31 Oct 2021 11:21:06 +0530 Subject: [PATCH 05/33] added arbitrary args and arbitrary keyword args while executing a function synchronously from offload_task() in inventree.tasks --- InvenTree/InvenTree/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index da1d29d76a..e623d7a98c 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -110,7 +110,7 @@ def offload_task(taskname, *args, force_sync=False, **kwargs): return # Workers are not running: run it as synchronous task - _func() + _func(*args, **kwargs) def heartbeat(): From 40da41959bffc677d940c1cd77245a7ddee3af9b Mon Sep 17 00:00:00 2001 From: rocheparadox Date: Sun, 31 Oct 2021 11:26:41 +0530 Subject: [PATCH 06/33] Created part.tasks file and moved notify_low_stock function to the same from InvenTree.tasks. The argument type is changed from StockItem to Part Added trans to headers of table in email template of low_stock_notification.html added is_part_low_on_stock() function to the part model to check if the part's stock has fallen below the minimum quantity used offload_task function to run the low stock notification function asynchronously --- InvenTree/InvenTree/tasks.py | 27 ------------- InvenTree/part/models.py | 3 ++ InvenTree/part/tasks.py | 39 +++++++++++++++++++ InvenTree/stock/models.py | 7 +++- .../stock/low_stock_notification.html | 8 ++-- 5 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 InvenTree/part/tasks.py diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index e623d7a98c..4fa7409326 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -310,30 +310,3 @@ def send_email(subject, body, recipients, from_email=None, html_message=None): fail_silently=False, html_message=html_message ) - - -def notify_low_stock(stock_item): - """ - Notify users who have starred a part when its stock quantity falls below the minimum threshold - """ - - from allauth.account.models import EmailAddress - starred_users = EmailAddress.objects.filter(user__starred_parts__part=stock_item.part) - - if len(starred_users) > 0: - logger.info(f"Notify users regarding low stock of {stock_item.part.name}") - context = { - 'part_name': stock_item.part.name, - # Part url can be used to open the page of part in application from the email. - # It can be facilitated when the application base url is accessible programmatically. - # 'part_url': f'{application_base_url}/part/{stock_item.part.id}', - - # quantity is in decimal field datatype. Since the same datatype is used in models, - # it is not converted to number/integer, - 'part_quantity': stock_item.quantity, - 'minimum_quantity': stock_item.part.minimum_stock - } - subject = _(f'Attention! {stock_item.part.name} is low on stock') - html_message = render_to_string('stock/low_stock_notification.html', context) - recipients = starred_users.values_list('email', flat=True) - send_email(subject, '', recipients, html_message=html_message) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 5cd9fa3180..050b46058a 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1988,6 +1988,9 @@ class Part(MPTTModel): def related_count(self): return len(self.get_related_parts()) + def is_part_low_on_stock(self): + return self.total_stock <= self.minimum_stock + def attach_file(instance, filename): """ Function for storing a file for a PartAttachment diff --git a/InvenTree/part/tasks.py b/InvenTree/part/tasks.py new file mode 100644 index 0000000000..667e70f1a9 --- /dev/null +++ b/InvenTree/part/tasks.py @@ -0,0 +1,39 @@ +# Author: Roche Christopher +# Created at 10:26 AM on 31/10/21 + +import logging + +from django.utils.translation import ugettext_lazy as _ +from django.template.loader import render_to_string + +from InvenTree import tasks as inventree_tasks +from part.models import Part + +logger = logging.getLogger("inventree") + + +def notify_low_stock(part: Part): + """ + Notify users who have starred a part when its stock quantity falls below the minimum threshold + """ + + from allauth.account.models import EmailAddress + starred_users_email = EmailAddress.objects.filter(user__starred_parts__part=part) + + if len(starred_users_email) > 0: + logger.info(f"Notify users regarding low stock of {part.name}") + context = { + 'part_name': part.name, + # Part url can be used to open the page of part in application from the email. + # It can be facilitated when the application base url is accessible programmatically. + # 'part_url': f'{application_base_url}/part/{stock_item.part.id}', + + # quantity is in decimal field datatype. Since the same datatype is used in models, + # it is not converted to number/integer, + 'part_quantity': part.total_stock, + 'minimum_quantity': part.minimum_stock + } + subject = _(f'Attention! {part.name} is low on stock') + 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) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index b4746e0879..69b061d25a 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -1659,8 +1659,11 @@ def after_save_stock_item(sender, instance: StockItem, **kwargs): starred the part """ - if instance.quantity <= instance.part.minimum_stock: - inventree_tasks.notify_low_stock(instance) + if instance.part.is_part_low_on_stock(): + inventree_tasks.offload_task( + 'part.tasks.notify_low_stock', + instance.part + ) class StockItemAttachment(InvenTreeAttachment): diff --git a/InvenTree/stock/templates/stock/low_stock_notification.html b/InvenTree/stock/templates/stock/low_stock_notification.html index 04ada64e18..3126cd11c1 100644 --- a/InvenTree/stock/templates/stock/low_stock_notification.html +++ b/InvenTree/stock/templates/stock/low_stock_notification.html @@ -5,13 +5,13 @@ - + - - - + + + From 60c2aab06d395bac99e5dcd6ed6d034c55298d29 Mon Sep 17 00:00:00 2001 From: rocheparadox Date: Sun, 31 Oct 2021 11:30:14 +0530 Subject: [PATCH 07/33] remove unused imports --- InvenTree/InvenTree/tasks.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index 4fa7409326..801c75aa26 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -11,8 +11,6 @@ from django.utils import timezone from django.core.exceptions import AppRegistryNotReady from django.db.utils import OperationalError, ProgrammingError -from django.template.loader import render_to_string -from django.utils.translation import gettext_lazy as _ logger = logging.getLogger("inventree") From f0a558c1e2241af5c096b548feda1cf5387c0343 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Nov 2021 00:06:08 +0100 Subject: [PATCH 08/33] remove unneeded spacing --- InvenTree/InvenTree/static/css/inventree.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index a1cabc0435..3426a2a1a9 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -545,7 +545,6 @@ .inventree-body { width: 100%; padding: 5px; - margin-top: 10px; } .inventree-pre-content { @@ -562,10 +561,6 @@ transition: 0.1s; } -.body { - padding-top: 50px; -} - .modal { overflow: hidden; z-index: 9999; From 2c9b03944fab8590507e97eb4a584ed9018825f1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Nov 2021 00:08:39 +0100 Subject: [PATCH 09/33] remove breadcrub div where no breadcrumb --- InvenTree/templates/InvenTree/index.html | 2 ++ InvenTree/templates/InvenTree/search.html | 3 +++ InvenTree/templates/page_base.html | 3 +++ 3 files changed, 8 insertions(+) diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index eec261e056..95b6c15bf9 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -7,6 +7,8 @@ {% inventree_title %} | {% trans "Index" %} {% endblock %} +{% block breadcrumb_list %} +{% endblock %} {% block sidebar %} diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index 34f4a541fe..191a5a5b4c 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -8,6 +8,9 @@ {% inventree_title %} | {% trans "Search Results" %} {% endblock %} +{% block breadcrumb_list %} +{% endblock %} + {% block content %}
diff --git a/InvenTree/templates/page_base.html b/InvenTree/templates/page_base.html index 2a9704a728..7c0c808b8a 100644 --- a/InvenTree/templates/page_base.html +++ b/InvenTree/templates/page_base.html @@ -3,6 +3,9 @@ {% load static %} {% load i18n %} +{% block breadcrumb_list %} +{% endblock %} + {% block content %}
From 62aa014f6b43689cb832b50e1780cef1f537b095 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 1 Nov 2021 00:09:38 +0100 Subject: [PATCH 10/33] add button for navbar toogle --- InvenTree/templates/navbar.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index 8acc27b956..b0c921b5ec 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -10,7 +10,10 @@ -
Part low on stock{% trans "Part low on stock" %}
Part NameAvailable QuantityMinimum Quantity{% trans "Part Name" %}{% trans "Available Quantity" %}{% trans "Minimum Quantity" %}
- - - - - - - - - - - - - - - - - - - - - -
{% trans "Part low on stock" %}
{% trans "Part Name" %}{% trans "Available Quantity" %}{% trans "Minimum Quantity" %}
{{ part_name }}{{ part_quantity }}{{ minimum_quantity }}
{% trans "You are receiving this mail because you have starred the part " %} {{ part_name }} - {% trans "Inventree application" %} -
- diff --git a/InvenTree/templates/email/low_stock_notification.html b/InvenTree/templates/email/low_stock_notification.html new file mode 100644 index 0000000000..4fa4e55295 --- /dev/null +++ b/InvenTree/templates/email/low_stock_notification.html @@ -0,0 +1,35 @@ +{% load i18n %} +{% load inventree_extras %} + + + + + + + + + + + + + + + + + + + + + + + +
+

{% blocktrans with part=part.name %} The available stock for {{ part }} has fallen below the configured minimum level{% endblocktrans %}

+ {% if link %} +

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

+ {% endif %} +
{% trans "Part Name" %}{% trans "Available Quantity" %}{% trans "Minimum Quantity" %}
{{ part.full_name }}{{ part.total_stock }}{{ part.minimum_stock }}
+

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

+

{% trans "InvenTree version" %}: {% inventree_version %}

+
+ From 2abcb114a8941e4228819a6f57bf4dba88ee0fbd Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 11:28:46 +1100 Subject: [PATCH 19/33] Visual improvements for "currency" page --- .../InvenTree/settings/currencies.html | 18 ++++++++++-------- InvenTree/templates/panel.html | 8 +++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings/currencies.html b/InvenTree/templates/InvenTree/settings/currencies.html index ba6e782508..706f836317 100644 --- a/InvenTree/templates/InvenTree/settings/currencies.html +++ b/InvenTree/templates/InvenTree/settings/currencies.html @@ -13,29 +13,31 @@ {% include "InvenTree/settings/setting.html" with key="INVENTREE_DEFAULT_CURRENCY" icon="fa-globe" %} - -
- - + - + + {% for rate in rates %} - + + + + {% endfor %} + - diff --git a/InvenTree/templates/panel.html b/InvenTree/templates/panel.html index 1491991e8c..53c5ca997a 100644 --- a/InvenTree/templates/panel.html +++ b/InvenTree/templates/panel.html @@ -1,7 +1,13 @@
{% block panel_heading %}
-

{% block heading %}HEADING{% endblock %}

+
+

{% block heading %}HEADING{% endblock %}

+
+
+ {% block actions %} + {% endblock %} +
{% endblock %} {% block panel_content %} From 66b078e4b9b1e4a0b7675c756e5e91a9634eaadb Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 11:31:24 +1100 Subject: [PATCH 20/33] Refactor part settings page --- .../templates/InvenTree/settings/part.html | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 351810b7dc..1b2a3e5498 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -9,8 +9,6 @@ {% block content %} -

{% trans "Part Options" %}

-
{% trans "Base Currency" %} {{ base_currency }}
{% trans "Exchange Rates" %}{% trans "Exchange Rates" %}
{{ rate.currency }} {{ rate.value }}{{ rate.currency }}
{% trans "Last Update" %} + {% if rates_updated %} {{ rates_updated }} {% else %} @@ -44,7 +46,7 @@
{% csrf_token %} - +
{% include "InvenTree/settings/setting.html" with key="PART_IPN_REGEX" %} @@ -40,12 +38,17 @@
-

{% trans "Part Import" %}

- - - +
+
+

{% trans "Part Import" %}

+ {% include "spacer.html" %} +
+ +
+
+
@@ -53,14 +56,16 @@
- - -

{% trans "Part Parameter Templates" %}

- -
- +
+ +

{% trans "Part Parameter Templates" %}

+ {% include "spacer.html" %} +
+ +
+
From 489d085de83aa1d03f19f7491efa450335c90909 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 11:32:57 +1100 Subject: [PATCH 21/33] Refactor "category" settings page --- InvenTree/templates/InvenTree/settings/category.html | 12 ++++++------ InvenTree/templates/panel.html | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings/category.html b/InvenTree/templates/InvenTree/settings/category.html index 9eb595ddde..f90d1e8d11 100644 --- a/InvenTree/templates/InvenTree/settings/category.html +++ b/InvenTree/templates/InvenTree/settings/category.html @@ -7,6 +7,12 @@ {% trans "Category Settings" %} {% endblock %} +{% block actions %} + +{% endblock %} + {% block content %}
@@ -21,12 +27,6 @@
-
- -
-
diff --git a/InvenTree/templates/panel.html b/InvenTree/templates/panel.html index 53c5ca997a..86867f07b4 100644 --- a/InvenTree/templates/panel.html +++ b/InvenTree/templates/panel.html @@ -3,10 +3,11 @@

{% block heading %}HEADING{% endblock %}

-
-
- {% block actions %} - {% endblock %} + {% include "spacer.html" %} +
+ {% block actions %} + {% endblock %} +
{% endblock %} From d1f2d960be9f9b1cf4733e16d1aaf02b7b119aa0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 12:15:46 +1100 Subject: [PATCH 22/33] Refactor "user account" page --- .../templates/InvenTree/settings/user.html | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html index d6cbf998a7..29813465cd 100644 --- a/InvenTree/templates/InvenTree/settings/user.html +++ b/InvenTree/templates/InvenTree/settings/user.html @@ -11,18 +11,18 @@ {% trans "Account Settings" %} {% endblock %} +{% block actions %} +
+ {% trans "Edit" %} +
+
+ {% trans "Set Password" %} +
+{% endblock %} + {% block content %} {% mail_configured as mail_conf %} -
-
- {% trans "Edit" %} -
-
- {% trans "Set Password" %} -
-
- @@ -39,7 +39,10 @@
{% trans "Username" %}
-

{% trans "Email" %}

+
+

{% trans "Email" %}

+ {% include "spacer.html" %} +
@@ -89,8 +92,18 @@
{% csrf_token %} - {{ add_email_form|crispy }} - + + +
+
@
+ +
+ +
+
+
{% endif %}
From ec147ea25fbe85a5e6fbd9a50f22ad7b1d5411ca Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 12:49:44 +1100 Subject: [PATCH 23/33] Further work on email settings page --- .../templates/InvenTree/settings/user.html | 124 +++++++++--------- 1 file changed, 64 insertions(+), 60 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html index 29813465cd..1b5e507047 100644 --- a/InvenTree/templates/InvenTree/settings/user.html +++ b/InvenTree/templates/InvenTree/settings/user.html @@ -45,50 +45,51 @@
-
- {% if user.emailaddress_set.all %} -

{% trans 'The following email addresses are associated with your account:' %}

+
+
+ {% if user.emailaddress_set.all %} +

{% trans 'The following email addresses are associated with your account:' %}

- - + {% else %} +

{% trans 'Warning:'%} + {% trans "You currently do not have any email address set up. You should really add an email address so you can receive notifications, reset your password, etc." %} +

- {% else %} -

{% trans 'Warning:'%} - {% trans "You currently do not have any email address set up. You should really add an email address so you can receive notifications, reset your password, etc." %} -

- - {% endif %} - - {% if can_add_email %} -
-

{% trans "Add Email Address" %}

+ {% endif %} +
+
+ {% if can_add_email %} +
{% trans "Add Email Address" %}
{% csrf_token %} @@ -106,7 +107,7 @@
{% endif %} -
+
@@ -168,26 +169,26 @@
-
- {% csrf_token %} - -
-
-
- +
+ + {% csrf_token %} + + +
+ +
+
-
-
- -
- - + +
@@ -199,7 +200,10 @@
{% csrf_token %} -
+ +
-
-
- +
+ +
- +

{% trans "Help the translation efforts!" %}

From fc9ca5e48138e8f1f513d7c4af4d9fdbeea2e748 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 12:54:41 +1100 Subject: [PATCH 24/33] Pretty badges for email accounts --- .../templates/InvenTree/settings/user.html | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html index 1b5e507047..aaf16cf853 100644 --- a/InvenTree/templates/InvenTree/settings/user.html +++ b/InvenTree/templates/InvenTree/settings/user.html @@ -55,20 +55,26 @@
{% for emailaddress in user.emailaddress_set.all %} +
{% if emailaddress.verified %} - {% trans "Verified" %} + {% trans "Verified" %} {% else %} - {% trans "Unverified" %} + {% trans "Unverified" %} {% endif %} - {% if emailaddress.primary %}{% trans "Primary" %}{% endif %} - + {% if emailaddress.primary %}{% trans "Primary" %}{% endif %}
+
{% endfor %}
From a3889c709e5cc46fde650af5437166ceb69744d7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 12:57:40 +1100 Subject: [PATCH 25/33] More tweaks --- InvenTree/common/models.py | 6 +++--- InvenTree/templates/InvenTree/settings/login.html | 2 +- InvenTree/templates/InvenTree/settings/setting.html | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 3dae13c3e0..1809f437f7 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -807,19 +807,19 @@ class InvenTreeSetting(BaseInvenTreeSetting): # login / SSO 'LOGIN_ENABLE_PWD_FORGOT': { 'name': _('Enable password forgot'), - 'description': _('Enable password forgot function on the login-pages'), + 'description': _('Enable password forgot function on the login pages'), 'default': True, 'validator': bool, }, 'LOGIN_ENABLE_REG': { 'name': _('Enable registration'), - 'description': _('Enable self-registration for users on the login-pages'), + 'description': _('Enable self-registration for users on the login pages'), 'default': False, 'validator': bool, }, 'LOGIN_ENABLE_SSO': { 'name': _('Enable SSO'), - 'description': _('Enable SSO on the login-pages'), + 'description': _('Enable SSO on the login pages'), 'default': False, 'validator': bool, }, diff --git a/InvenTree/templates/InvenTree/settings/login.html b/InvenTree/templates/InvenTree/settings/login.html index d3cba1180f..96d986d6c7 100644 --- a/InvenTree/templates/InvenTree/settings/login.html +++ b/InvenTree/templates/InvenTree/settings/login.html @@ -17,7 +17,7 @@ {% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_PWD_FORGOT" icon="fa-info-circle" %} {% include "InvenTree/settings/setting.html" with key="LOGIN_MAIL_REQUIRED" icon="fa-info-circle" %} - {% trans 'Signup' %} +
{% trans 'Signup' %}
{% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_REG" icon="fa-info-circle" %} diff --git a/InvenTree/templates/InvenTree/settings/setting.html b/InvenTree/templates/InvenTree/settings/setting.html index 4a506b46e6..7419b7ff34 100644 --- a/InvenTree/templates/InvenTree/settings/setting.html +++ b/InvenTree/templates/InvenTree/settings/setting.html @@ -21,15 +21,13 @@
{% else %}
- {% if setting.value %} - {{ setting.value }} + {{ setting.value }} {% else %} - {% trans "No value set" %} + {% trans "No value set" %} {% endif %} - {{ setting.units }}
{% endif %} From e3dfb6cbc8f3d2c8cb9c7a25b21771dc4d2d80f5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 13:08:10 +1100 Subject: [PATCH 26/33] Improve messaging --- InvenTree/templates/InvenTree/settings/user.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html index aaf16cf853..d1baf1ba6e 100644 --- a/InvenTree/templates/InvenTree/settings/user.html +++ b/InvenTree/templates/InvenTree/settings/user.html @@ -155,7 +155,9 @@ {% else %} -

{% trans 'You currently have no social network accounts connected to this account.' %}

+
+ {% trans "There are no social network accounts connected to your InvenTree account" %} +
{% endif %}
From 1dea7861d053ad699c51531dac446b81946c1eb0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 14:43:57 +1100 Subject: [PATCH 27/33] Refactor email body out into a template - Will be useful in the future when more email functionality is implemented --- InvenTree/templates/email/email.html | 43 +++++++++++++++ .../email/low_stock_notification.html | 52 ++++++++----------- 2 files changed, 66 insertions(+), 29 deletions(-) create mode 100644 InvenTree/templates/email/email.html diff --git a/InvenTree/templates/email/email.html b/InvenTree/templates/email/email.html new file mode 100644 index 0000000000..97e9a40f37 --- /dev/null +++ b/InvenTree/templates/email/email.html @@ -0,0 +1,43 @@ +{% load i18n %} +{% load static %} +{% load inventree_extras %} + + + + {% block header %} + + + + + {% endblock %} + + {% block body %} + + {% block body_row %} + + {% endblock %} + + {% endblock %} + + {% block footer %} + + + + {% endblock %} + +
+ {% block header_row %} +

{% block title %}{% endblock %}

+ {% block subtitle %} + + {% endblock %} + {% endblock %} +
+ {% block footer_prefix %} + + {% endblock %} +

{% trans "InvenTree version" %}: {% inventree_version %} - inventree.readthedocs.io

+ {% block footer_suffix %} + + {% endblock %} +
diff --git a/InvenTree/templates/email/low_stock_notification.html b/InvenTree/templates/email/low_stock_notification.html index 4fa4e55295..ecb350925a 100644 --- a/InvenTree/templates/email/low_stock_notification.html +++ b/InvenTree/templates/email/low_stock_notification.html @@ -1,35 +1,29 @@ +{% extends "email/email.html" %} + {% load i18n %} {% load inventree_extras %} - +{% block title %} +{% blocktrans with part=part.name %} The available stock for {{ part }} has fallen below the configured minimum level{% endblocktrans %} +{% if link %} +

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

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

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

+{% endblock %} - - - - - - - - - - - - - - - - -
-

{% blocktrans with part=part.name %} The available stock for {{ part }} has fallen below the configured minimum level{% endblocktrans %}

- {% if link %} -

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

- {% endif %} -
{% trans "Part Name" %}{% trans "Available Quantity" %}{% trans "Minimum Quantity" %}
{{ part.full_name }}{{ part.total_stock }}{{ part.minimum_stock }}
-

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

-

{% trans "InvenTree version" %}: {% inventree_version %}

-
+{% block body %} + + {% trans "Part Name" %} + {% trans "Available Quantity" %} + {% trans "Minimum Quantity" %} + + + {{ part.full_name }} + {{ part.total_stock }} + {{ part.minimum_stock }} + +{% endblock %} From c636f13ba8dd6d5dcfd768c560eeb164720b398a Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 11:44:42 +1100 Subject: [PATCH 28/33] Template fix for BOM upload --- .../part/bom_upload/upload_file.html | 91 +++++++++---------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/InvenTree/part/templates/part/bom_upload/upload_file.html b/InvenTree/part/templates/part/bom_upload/upload_file.html index c8add61f49..ab3b245010 100644 --- a/InvenTree/part/templates/part/bom_upload/upload_file.html +++ b/InvenTree/part/templates/part/bom_upload/upload_file.html @@ -8,58 +8,55 @@ {% include "sidebar_link.html" with url=url text="Return to BOM" icon="fa-undo" %} {% endblock %} -{% block page_content %} +{% block heading %} +{% trans "Upload Bill of Materials" %} +{% endblock %} -
-
- {% block heading %} -

{% trans "Upload Bill of Materials" %}

- {{ wizard.form.media }} - {% endblock %} +{% block actions %} +{% endblock %} + +{% block page_info %} +
+

{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %} + {% if description %}- {{ description }}{% endif %}

+ +
+ {% csrf_token %} + {% load crispy_forms_tags %} + + {% block form_buttons_top %} + {% endblock form_buttons_top %} + + {% block form_alert %} +
+ {% trans "Requirements for BOM upload" %}: +
    +
  • {% trans "The BOM file must contain the required named columns as provided in the " %} {% trans "BOM Upload Template" %}
  • +
  • {% trans "Each part must already exist in the database" %}
  • +
-
- {% block details %} + {% endblock %} -

{% blocktrans with step=wizard.steps.step1 count=wizard.steps.count %}Step {{step}} of {{count}}{% endblocktrans %} - {% if description %}- {{ description }}{% endif %}

+ + {{ wizard.management_form }} + {% block form_content %} + {% crispy wizard.form %} + {% endblock form_content %} +
- - {% csrf_token %} - {% load crispy_forms_tags %} - - {% block form_buttons_top %} - {% endblock form_buttons_top %} - - {% block form_alert %} -
- {% trans "Requirements for BOM upload" %}: -
    -
  • {% trans "The BOM file must contain the required named columns as provided in the " %} {% trans "BOM Upload Template" %}
  • -
  • {% trans "Each part must already exist in the database" %}
  • -
-
- {% endblock %} - - - {{ wizard.management_form }} - {% block form_content %} - {% crispy wizard.form %} - {% endblock form_content %} -
- - {% block form_buttons_bottom %} - {% if wizard.steps.prev %} - - {% endif %} - - - {% endblock form_buttons_bottom %} - - {% endblock details %} -
- -{% endblock page_content %} + {% block form_buttons_bottom %} + {% if wizard.steps.prev %} + + {% endif %} + + + {% endblock form_buttons_bottom %} +
+{% endblock page_info %} {% block js_ready %} {{ block.super }} + +enableSidebar('bom-upload'); + {% endblock js_ready %} From b1c23e30f5fc83af8edbf63b4973ddd11679be4c Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 11:59:20 +1100 Subject: [PATCH 29/33] Fix CSS for user badges --- InvenTree/build/templates/build/detail.html | 2 +- InvenTree/order/templates/order/order_base.html | 4 ++-- InvenTree/order/templates/order/sales_order_base.html | 6 +++--- InvenTree/part/templates/part/detail.html | 2 +- InvenTree/stock/templates/stock/item_base.html | 2 +- InvenTree/stock/templates/stock/location_delete.html | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 9400eb6473..d53122cdd1 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -142,7 +142,7 @@ {% trans "Completed" %} {% if build.completion_date %} - {{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }}{% endif %} + {{ build.completion_date }}{% if build.completed_by %}{{ build.completed_by }}{% endif %} {% else %} {% trans "Build not complete" %} {% endif %} diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 9e94b379f8..83a17a705a 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -123,7 +123,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Created" %} - {{ order.creation_date }}{{ order.created_by }} + {{ order.creation_date }}{{ order.created_by }} {% if order.issue_date %} @@ -143,7 +143,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Received" %} - {{ order.complete_date }}{{ order.received_by }} + {{ order.complete_date }}{{ order.received_by }} {% endif %} {% if order.responsible %} diff --git a/InvenTree/order/templates/order/sales_order_base.html b/InvenTree/order/templates/order/sales_order_base.html index 42a09e8ede..952319da10 100644 --- a/InvenTree/order/templates/order/sales_order_base.html +++ b/InvenTree/order/templates/order/sales_order_base.html @@ -128,7 +128,7 @@ src="{% static 'img/blank_image.png' %}" {% trans "Created" %} - {{ order.creation_date }}{{ order.created_by }} + {{ order.creation_date }}{{ order.created_by }} {% if order.target_date %} @@ -141,14 +141,14 @@ src="{% static 'img/blank_image.png' %}" {% trans "Shipped" %} - {{ order.shipment_date }}{{ order.shipped_by }} + {{ order.shipment_date }}{{ order.shipped_by }} {% endif %} {% if order.status == PurchaseOrderStatus.COMPLETE %} {% trans "Received" %} - {{ order.complete_date }}{{ order.received_by }} + {{ order.complete_date }}{{ order.received_by }} {% endif %} {% if order.responsible %} diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 145b5bfb35..e45e7e14b8 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -64,7 +64,7 @@ {{ part.creation_date }} {% if part.creation_user %} - {{ part.creation_user }} + {{ part.creation_user }} {% endif %} diff --git a/InvenTree/stock/templates/stock/item_base.html b/InvenTree/stock/templates/stock/item_base.html index 5a58e2e04f..8da0db0296 100644 --- a/InvenTree/stock/templates/stock/item_base.html +++ b/InvenTree/stock/templates/stock/item_base.html @@ -393,7 +393,7 @@ {% trans "Last Stocktake" %} {% if item.stocktake_date %} - {{ item.stocktake_date }} {{ item.stocktake_user }} + {{ item.stocktake_date }} {{ item.stocktake_user }} {% else %} {% trans "No stocktake performed" %} {% endif %} diff --git a/InvenTree/stock/templates/stock/location_delete.html b/InvenTree/stock/templates/stock/location_delete.html index 22b4168173..9c560e58c5 100644 --- a/InvenTree/stock/templates/stock/location_delete.html +++ b/InvenTree/stock/templates/stock/location_delete.html @@ -36,7 +36,7 @@ If this location is deleted, these items will be moved to the top level 'Stock'
    {% for item in location.stock_items.all %} -
  • {{ item.part.full_name }} - {{ item.part.description }}{% decimal item.quantity %}
  • +
  • {{ item.part.full_name }} - {{ item.part.description }}{% decimal item.quantity %}
  • {% endfor %}
{% endif %} From c4ea3ecf6fc3eb4e2db69c16218ac44b2d219cf0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 13:27:58 +1100 Subject: [PATCH 30/33] Bug fix for stock location table (cherry picked from commit 44794d7b78520023e3b70da61dc13938bfd4bd14) --- InvenTree/stock/templates/stock/location.html | 3 +- InvenTree/templates/js/translated/stock.js | 52 +++++++++++-------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index 7490d262bd..521a7bdca8 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -183,7 +183,8 @@ {% else %} parent: 'null', {% endif %} - } + }, + allowTreeView: true, }); linkButtonsToSelection( diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index 62e765b25b..04a27f6682 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1416,8 +1416,11 @@ function loadStockTable(table, options) { }); } + +/* + * Display a table of stock locations + */ function loadStockLocationTable(table, options) { - /* Display a table of stock locations */ var params = options.params || {}; @@ -1443,15 +1446,15 @@ function loadStockLocationTable(table, options) { filters[key] = params[key]; } - var tree_view = inventreeLoad('location-tree-view') == 1; + var tree_view = options.allowTreeView && inventreeLoad('location-tree-view') == 1; table.inventreeTable({ - treeEnable: tree_view, + treeEnable: options.allowTreeView && tree_view, rootParentId: options.params.parent, uniqueId: 'pk', idField: 'pk', treeShowField: 'name', - parentIdField: 'parent', + parentIdField: tree_view ? 'parent' : null, disablePagination: tree_view, sidePagination: tree_view ? 'client' : 'server', serverSort: !tree_view, @@ -1465,28 +1468,31 @@ function loadStockLocationTable(table, options) { showColumns: true, onPostBody: function() { - tree_view = inventreeLoad('location-tree-view') == 1; + if (options.allowTreeView) { - if (tree_view) { + tree_view = inventreeLoad('location-tree-view') == 1; - $('#view-location-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); - $('#view-location-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); - - table.treegrid({ - treeColumn: 1, - onChange: function() { - table.bootstrapTable('resetView'); - }, - onExpand: function() { - - } - }); - } else { - $('#view-location-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); - $('#view-location-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); + if (tree_view) { + + $('#view-location-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); + $('#view-location-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); + + table.treegrid({ + treeColumn: 1, + onChange: function() { + table.bootstrapTable('resetView'); + }, + onExpand: function() { + + } + }); + } else { + $('#view-location-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); + $('#view-location-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); + } } }, - buttons: [ + buttons: options.allowTreeView ? [ { icon: 'fas fa-bars', attributes: { @@ -1525,7 +1531,7 @@ function loadStockLocationTable(table, options) { ); } } - ], + ] : [], columns: [ { checkbox: true, From 08ffa102c627b5ad6b4cf83c5183060dc3f2dd33 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 13:33:38 +1100 Subject: [PATCH 31/33] Fixes for part category table (cherry picked from commit f7ef309995f8a52c213748f4a9226724e288c936) --- InvenTree/part/templates/part/category.html | 3 +- InvenTree/templates/js/translated/part.js | 51 +++++++++++---------- InvenTree/templates/js/translated/stock.js | 4 +- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 6672adf210..03369b093d 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -210,7 +210,8 @@ {% else %} parent: null, {% endif %} - } + }, + allowTreeView: true, } ); diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js index ec72d2682c..44295e67ea 100644 --- a/InvenTree/templates/js/translated/part.js +++ b/InvenTree/templates/js/translated/part.js @@ -1133,8 +1133,10 @@ function loadPartTable(table, url, options={}) { } +/* + * Display a table of part categories + */ function loadPartCategoryTable(table, options) { - /* Display a table of part categories */ var params = options.params || {}; @@ -1157,15 +1159,15 @@ function loadPartCategoryTable(table, options) { setupFilterList(filterKey, table, filterListElement); - var tree_view = inventreeLoad('category-tree-view') == 1; + var tree_view = options.allowTreeView && inventreeLoad('category-tree-view') == 1; table.inventreeTable({ treeEnable: tree_view, - rootParentId: options.params.parent, + rootParentId: tree_view ? options.params.parent : null, uniqueId: 'pk', idField: 'pk', treeShowField: 'name', - parentIdField: 'parent', + parentIdField: tree_view ? 'parent' : null, method: 'get', url: options.url || '{% url "api-part-category-list" %}', queryParams: filters, @@ -1176,7 +1178,7 @@ function loadPartCategoryTable(table, options) { name: 'category', original: original, showColumns: true, - buttons: [ + buttons: options.allowTreeView ? [ { icon: 'fas fa-bars', attributes: { @@ -1215,28 +1217,31 @@ function loadPartCategoryTable(table, options) { ); } } - ], + ] : [], onPostBody: function() { - tree_view = inventreeLoad('category-tree-view') == 1; + if (options.allowTreeView) { - if (tree_view) { + tree_view = inventreeLoad('category-tree-view') == 1; - $('#view-category-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); - $('#view-category-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); - - table.treegrid({ - treeColumn: 0, - onChange: function() { - table.bootstrapTable('resetView'); - }, - onExpand: function() { - - } - }); - } else { - $('#view-category-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); - $('#view-category-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); + if (tree_view) { + + $('#view-category-list').removeClass('btn-secondary').addClass('btn-outline-secondary'); + $('#view-category-tree').removeClass('btn-outline-secondary').addClass('btn-secondary'); + + table.treegrid({ + treeColumn: 0, + onChange: function() { + table.bootstrapTable('resetView'); + }, + onExpand: function() { + + } + }); + } else { + $('#view-category-tree').removeClass('btn-secondary').addClass('btn-outline-secondary'); + $('#view-category-list').removeClass('btn-outline-secondary').addClass('btn-secondary'); + } } }, columns: [ diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js index 04a27f6682..261cb4d1d6 100644 --- a/InvenTree/templates/js/translated/stock.js +++ b/InvenTree/templates/js/translated/stock.js @@ -1449,8 +1449,8 @@ function loadStockLocationTable(table, options) { var tree_view = options.allowTreeView && inventreeLoad('location-tree-view') == 1; table.inventreeTable({ - treeEnable: options.allowTreeView && tree_view, - rootParentId: options.params.parent, + treeEnable: tree_view, + rootParentId: tree_view ? options.params.parent : null, uniqueId: 'pk', idField: 'pk', treeShowField: 'name', From d435689562f996d4e393403d0c260a08d933862f Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 13:57:50 +1100 Subject: [PATCH 32/33] Add more information to the "part details" tab --- InvenTree/part/templates/part/detail.html | 32 +++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index e45e7e14b8..1bc4b9b967 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -20,13 +20,6 @@ - {% if part.IPN %} - - - - - - {% endif %} @@ -37,6 +30,13 @@ + {% if part.IPN %} + + + + + + {% endif %} {% if part.revision %} @@ -44,6 +44,20 @@ {% endif %} + {% if part.units %} + + + + + + {% endif %} + {% if part.minimum_stock %} + + + + + + {% endif %} {% if part.keywords %} @@ -79,7 +93,9 @@ - + {% endif %} {% if part.default_supplier %} From 31ea71d3913f6be45922f7cc65e6ba0593838107 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 3 Nov 2021 14:00:13 +1100 Subject: [PATCH 33/33] Display part category --- InvenTree/part/templates/part/detail.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 1bc4b9b967..fc9795b6e0 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -30,6 +30,15 @@ + {% if part.category %} + + + + + + {% endif %} {% if part.IPN %}
{% trans "IPN" %}{{ part.IPN }}{% include "clip.html"%}
{% trans "Name" %}{% trans "Description" %} {{ part.description }}{% include "clip.html"%}
{% trans "IPN" %}{{ part.IPN }}{% include "clip.html"%}
{{ part.revision }}{% include "clip.html"%}
{% trans "Units" %}{{ part.units }}
{% trans "Minimum stock level" %}{{ part.minimum_stock }}
{% trans "Default Location" %}{{ part.default_location }} + {{ part.default_location }} +
{% trans "Description" %} {{ part.description }}{% include "clip.html"%}
{% trans "Category" %} + {{ part.category }} +