From 8c529240209c6dd185cb1f12fa85230ced9c18a0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 3 Feb 2022 16:16:42 +1100 Subject: [PATCH 1/4] Adds new setting to optionally display or hide part pricing information --- InvenTree/common/models.py | 12 ++++++++++++ InvenTree/templates/InvenTree/settings/part.html | 1 + 2 files changed, 13 insertions(+) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index ba475e75b8..9ef5a4d0c3 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -776,6 +776,18 @@ class InvenTreeSetting(BaseInvenTreeSetting): 'validator': bool, }, + # 2022-02-03 + # This setting exists as an interim solution for extremely slow part page load times when the part has a complex BOM + # In an upcoming release, pricing history (and BOM pricing) will be cached, + # rather than having to be re-calculated every time the page is loaded! + # For now, we will simply hide part pricing by default + 'PART_SHOW_PRICE_HISTORY': { + 'name': _('Show Price History'), + 'description': _('Display historical pricing for Part'), + 'default': False, + 'validator': bool, + }, + 'PART_SHOW_RELATED': { 'name': _('Show related parts'), 'description': _('Display related parts for a part'), diff --git a/InvenTree/templates/InvenTree/settings/part.html b/InvenTree/templates/InvenTree/settings/part.html index 1b2a3e5498..4f9841aaaf 100644 --- a/InvenTree/templates/InvenTree/settings/part.html +++ b/InvenTree/templates/InvenTree/settings/part.html @@ -15,6 +15,7 @@ {% include "InvenTree/settings/setting.html" with key="PART_ALLOW_DUPLICATE_IPN" %} {% include "InvenTree/settings/setting.html" with key="PART_ALLOW_EDIT_IPN" %} {% include "InvenTree/settings/setting.html" with key="PART_NAME_FORMAT" %} + {% include "InvenTree/settings/setting.html" with key="PART_SHOW_PRICE_HISTORY" icon="fa-history" %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_PRICE_IN_FORMS" icon="fa-dollar-sign" %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_PRICE_IN_BOM" icon="fa-dollar-sign" %} {% include "InvenTree/settings/setting.html" with key="PART_SHOW_RELATED" icon="fa-random" %} From 525b6d399d52552e185b18ea6e8c39e964cdedb6 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 3 Feb 2022 16:23:52 +1100 Subject: [PATCH 2/4] Hide pricing history tab if not enabled --- InvenTree/part/templates/part/detail.html | 3 +++ InvenTree/part/templates/part/part_sidebar.html | 3 +++ 2 files changed, 6 insertions(+) diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 9082285bdb..2266b39048 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -126,9 +126,12 @@ +{% settings_value "PART_SHOW_PRICE_HISTORY" as show_price_history %} +{% if show_price_history %}
{% include "part/prices.html" %}
+{% endif %}
diff --git a/InvenTree/part/templates/part/part_sidebar.html b/InvenTree/part/templates/part/part_sidebar.html index a8f57aa7b0..82246da559 100644 --- a/InvenTree/part/templates/part/part_sidebar.html +++ b/InvenTree/part/templates/part/part_sidebar.html @@ -4,6 +4,7 @@ {% settings_value "PART_INTERNAL_PRICE" as show_internal_price %} {% settings_value 'PART_SHOW_RELATED' as show_related %} +{% settings_value "PART_SHOW_PRICE_HISTORY" as show_price_history %} {% trans "Parameters" as text %} {% include "sidebar_item.html" with label="part-parameters" text=text icon="fa-th-list" %} @@ -25,8 +26,10 @@ {% trans "Used In" as text %} {% include "sidebar_item.html" with label="used-in" text=text icon="fa-layer-group" %} {% endif %} +{% if show_price_history %} {% trans "Pricing" as text %} {% include "sidebar_item.html" with label="pricing" text=text icon="fa-dollar-sign" %} +{% endif %} {% if part.salable or part.component %} {% trans "Allocations" as text %} {% include "sidebar_item.html" with label="allocations" text=text icon="fa-bookmark" %} From 722e94774593474cb9723fe4b48ed94e22ab610c Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 3 Feb 2022 16:30:48 +1100 Subject: [PATCH 3/4] Only calculate pricing data if required --- InvenTree/part/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index dc6b8a9632..97485ebe32 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -395,10 +395,11 @@ class PartDetail(InvenTreeRoleMixin, DetailView): context.update(**ctx) # Pricing information - ctx = self.get_pricing(self.get_quantity()) - ctx['form'] = self.form_class(initial=self.get_initials()) + if InvenTreeSetting.get_setting('PART_SHOW_PRICE_HISTORY', False): + ctx = self.get_pricing(self.get_quantity()) + ctx['form'] = self.form_class(initial=self.get_initials()) - context.update(ctx) + context.update(ctx) return context From c12191d3ed1fa15bdaf4aae62da16d91727d3674 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 3 Feb 2022 16:33:10 +1100 Subject: [PATCH 4/4] Disable multi-level BOM requests --- InvenTree/templates/js/translated/bom.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js index 6e4bfdcf25..71c6b0b387 100644 --- a/InvenTree/templates/js/translated/bom.js +++ b/InvenTree/templates/js/translated/bom.js @@ -778,6 +778,11 @@ function loadBomTable(table, options={}) { // This function may be called recursively for multi-level BOMs function requestSubItems(bom_pk, part_pk) { + // TODO: 2022-02-03 Currently, multi-level BOMs are not actually displayed. + + // Re-enable this function once multi-level display has been re-deployed + return; + inventreeGet( options.bom_url, {