diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 0d8a84a5d7..6ae31d6f5f 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -69,6 +69,35 @@ def getStaticUrl(filename): return os.path.join(STATIC_URL, str(filename)) +def construct_absolute_url(*arg): + """ + Construct (or attempt to construct) an absolute URL from a relative URL. + + This is useful when (for example) sending an email to a user with a link + to something in the InvenTree web framework. + + This requires the BASE_URL configuration option to be set! + """ + + base = str(InvenTreeSetting.get_setting('INVENTREE_BASE_URL')) + + url = '/'.join(arg) + + if not base: + return url + + # Strip trailing slash from base url + if base.endswith('/'): + base = base[:-1] + + if url.startswith('/'): + url = url[1:] + + url = f"{base}/{url}" + + return url + + def getBlankImage(): """ Return the qualified path for the 'blank image' placeholder. diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css index a1cabc0435..61037c9c54 100644 --- a/InvenTree/InvenTree/static/css/inventree.css +++ b/InvenTree/InvenTree/static/css/inventree.css @@ -141,6 +141,10 @@ float: left; } +.navbar-spacer { + height: 60px; +} + #navbar-barcode-li { border-left: none; border-right: none; @@ -545,7 +549,6 @@ .inventree-body { width: 100%; padding: 5px; - margin-top: 10px; } .inventree-pre-content { @@ -562,10 +565,6 @@ transition: 0.1s; } -.body { - padding-top: 50px; -} - .modal { overflow: hidden; z-index: 9999; diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index aa17ef8603..801c75aa26 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -52,7 +52,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, @@ -108,7 +108,7 @@ def offload_task(taskname, force_sync=False, *args, **kwargs): return # Workers are not running: run it as synchronous task - _func() + _func(*args, **kwargs) def heartbeat(): @@ -290,7 +290,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 +306,5 @@ def send_email(subject, body, recipients, from_email=None): from_email, recipients, fail_silently=False, + html_message=html_message ) 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 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/common/models.py b/InvenTree/common/models.py index 5daef948e8..8b5f1bbd98 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -830,19 +830,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/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/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..72d996e772 --- /dev/null +++ b/InvenTree/part/tasks.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +import logging + +from django.utils.translation import ugettext_lazy as _ +from django.template.loader import render_to_string + +from allauth.account.models import EmailAddress + +from common.models import InvenTree + +import InvenTree.helpers +import 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 + """ + + logger.info(f"Sending low stock notification email for {part.full_name}") + + starred_users_email = EmailAddress.objects.filter(user__starred_parts__part=part) + + # TODO: In the future, include the part image in the email template + + if len(starred_users_email) > 0: + logger.info(f"Notify users regarding low stock of {part.name}") + context = { + # Pass the "Part" object through to the template context + 'part': part, + 'link': InvenTree.helpers.construct_absolute_url(part.get_absolute_url()), + } + + subject = _(f'[InvenTree] {part.name} is low on stock') + html_message = render_to_string('email/low_stock_notification.html', context) + recipients = starred_users_email.values_list('email', flat=True) + + InvenTree.tasks.send_email(subject, '', recipients, html_message=html_message) + + +def notify_low_stock_if_required(part: Part): + """ + Check if the stock quantity has fallen below the minimum threshold of part. + + If true, notify the users who have subscribed to the part + """ + + if part.is_part_low_on_stock(): + InvenTree.tasks.offload_task( + 'part.tasks.notify_low_stock', + part + ) 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 %} 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/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 145b5bfb35..fc9795b6e0 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,22 @@ + {% if part.category %} + + + + + + {% endif %} + {% if part.IPN %} + + + + + + {% endif %} {% if part.revision %} @@ -44,6 +53,20 @@ {% endif %} + {% if part.units %} + + + + + + {% endif %} + {% if part.minimum_stock %} + + + + + + {% endif %} {% if part.keywords %} @@ -64,7 +87,7 @@ @@ -79,7 +102,9 @@ - + {% endif %} {% if part.default_supplier %} diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 2230077a81..590ea20a6f 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -122,6 +122,12 @@ def inventree_title(*args, **kwargs): return version.inventreeInstanceTitle() +@register.simple_tag() +def inventree_base_url(*args, **kwargs): + """ Return the INVENTREE_BASE_URL setting """ + return InvenTreeSetting.get_setting('INVENTREE_BASE_URL') + + @register.simple_tag() def python_version(*args, **kwargs): """ diff --git a/InvenTree/report/templatetags/report.py b/InvenTree/report/templatetags/report.py index 45d11c1d2d..9593db1885 100644 --- a/InvenTree/report/templatetags/report.py +++ b/InvenTree/report/templatetags/report.py @@ -14,6 +14,8 @@ from stock.models import StockItem from common.models import InvenTreeSetting +import InvenTree.helpers + register = template.Library() @@ -119,18 +121,10 @@ def internal_link(link, text): text = str(text) - base_url = InvenTreeSetting.get_setting('INVENTREE_BASE_URL') + url = InvenTree.helpers.construct_absolute_url(link) # If the base URL is not set, just return the text - if not base_url: + if not url: return text - if not base_url.endswith('/'): - base_url += '/' - - if base_url.endswith('/') and link.startswith('/'): - link = link[1:] - - url = f"{base_url}{link}" - return mark_safe(f'{text}') diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 1372e63406..657469a744 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, post_delete from django.dispatch import receiver from markdownx.models import MarkdownxField @@ -41,6 +41,7 @@ from users.models import Owner from company import models as CompanyModels from part import models as PartModels +from part import tasks as part_tasks class StockLocation(InvenTreeTree): @@ -1651,6 +1652,24 @@ def before_delete_stock_item(sender, instance, using, **kwargs): child.save() +@receiver(post_delete, sender=StockItem, dispatch_uid='stock_item_post_delete_log') +def after_delete_stock_item(sender, instance: StockItem, **kwargs): + """ + Function to be executed after a StockItem object is deleted + """ + + part_tasks.notify_low_stock_if_required(instance.part) + + +@receiver(post_save, sender=StockItem, dispatch_uid='stock_item_post_save_log') +def after_save_stock_item(sender, instance: StockItem, **kwargs): + """ + Hook function to be executed after StockItem object is saved/updated + """ + + part_tasks.notify_low_stock_if_required(instance.part) + + class StockItemAttachment(InvenTreeAttachment): """ Model for storing file attachments against a StockItem object. 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 @@ {% if item.stocktake_date %} - + {% else %} {% endif %} 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/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' {% endif %} 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/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 @@
-
- -
-
{% trans "IPN" %}{{ part.IPN }}{% include "clip.html"%}
{% trans "Name" %}{% trans "Description" %} {{ part.description }}{% include "clip.html"%}
{% trans "Category" %} + {{ part.category }} +
{% trans "IPN" %}{{ part.IPN }}{% include "clip.html"%}
{{ part.revision }}{% include "clip.html"%}
{% trans "Units" %}{{ part.units }}
{% trans "Minimum stock level" %}{{ part.minimum_stock }}
{{ part.creation_date }} {% if part.creation_user %} - {{ part.creation_user }} + {{ part.creation_user }} {% endif %}
{% trans "Default Location" %}{{ part.default_location }} + {{ part.default_location }} +
{% trans "Last Stocktake" %}{{ item.stocktake_date }} {{ item.stocktake_user }}{{ item.stocktake_date }} {{ item.stocktake_user }}{% trans "No stocktake performed" %}
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/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" %} - + {% include "InvenTree/settings/setting.html" with key="LOGIN_ENABLE_REG" icon="fa-info-circle" %} 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 %} - +
{% trans 'Signup' %}
{% trans 'Signup' %}
{% 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" %} +
+ +
+
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 %} diff --git a/InvenTree/templates/InvenTree/settings/user.html b/InvenTree/templates/InvenTree/settings/user.html index d6cbf998a7..d1baf1ba6e 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,61 +39,81 @@
{% trans "Username" %}
-

{% trans "Email" %}

+
+

{% trans "Email" %}

+ {% include "spacer.html" %} +
-
- {% 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 %} - {{ add_email_form|crispy }} - + + +
+
@
+ +
+ +
+
+
{% endif %} -
+
@@ -135,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 %}
@@ -155,26 +177,26 @@
-
- {% csrf_token %} - -
-
-
- +
+ + {% csrf_token %} + + +
+ +
+
-
-
- -
- - + +
@@ -186,7 +208,10 @@
{% csrf_token %} -
+ +
-
-
- +
+ +
- +

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

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 new file mode 100644 index 0000000000..ecb350925a --- /dev/null +++ b/InvenTree/templates/email/low_stock_notification.html @@ -0,0 +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 %} + +{% block body %} + + {% trans "Part Name" %} + {% trans "Available Quantity" %} + {% trans "Minimum Quantity" %} + + + + {{ part.full_name }} + {{ part.total_stock }} + {{ part.minimum_stock }} + +{% endblock %} 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 62e765b25b..261cb4d1d6 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, - rootParentId: options.params.parent, + rootParentId: tree_view ? options.params.parent : null, 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, diff --git a/InvenTree/templates/navbar.html b/InvenTree/templates/navbar.html index 38fcead610..c63031e3cb 100644 --- a/InvenTree/templates/navbar.html +++ b/InvenTree/templates/navbar.html @@ -12,7 +12,10 @@ -