From 1dea7861d053ad699c51531dac446b81946c1eb0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 2 Nov 2021 14:43:57 +1100 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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 }} +