From 13ef7d6910ee9a4bd2ccfd4a059c07cbcf8e29c9 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 26 Oct 2022 09:57:30 +1100 Subject: [PATCH] Enable build order search in quick-search window (#3856) * Add user setting to enable search preview for build orders * Add search results entry --- InvenTree/common/models.py | 7 +++++++ .../InvenTree/settings/user_search.html | 1 + InvenTree/templates/js/translated/search.js | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/InvenTree/common/models.py b/InvenTree/common/models.py index 25589c4887..3d7ddaab37 100644 --- a/InvenTree/common/models.py +++ b/InvenTree/common/models.py @@ -1612,6 +1612,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): 'validator': bool, }, + 'SEARCH_PREVIEW_SHOW_BUILD_ORDERS': { + 'name': _('Search Build Orders'), + 'description': _('Display build orders in search preview window'), + 'default': True, + 'validator': bool, + }, + 'SEARCH_PREVIEW_SHOW_PURCHASE_ORDERS': { 'name': _('Search Purchase Orders'), 'description': _('Display purchase orders in search preview window'), diff --git a/InvenTree/templates/InvenTree/settings/user_search.html b/InvenTree/templates/InvenTree/settings/user_search.html index da3180d4f3..2cd18f9641 100644 --- a/InvenTree/templates/InvenTree/settings/user_search.html +++ b/InvenTree/templates/InvenTree/settings/user_search.html @@ -23,6 +23,7 @@ {% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_HIDE_UNAVAILABLE_STOCK" user_setting=True icon='fa-eye-slash' %} {% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_LOCATIONS" user_setting=True icon='fa-sitemap' %} {% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_COMPANIES" user_setting=True icon='fa-building' %} + {% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_BUILD_ORDERS" user_setting=True icon='fa-tools' %} {% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_PURCHASE_ORDERS" user_setting=True icon='fa-shopping-cart' %} {% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_EXCLUDE_INACTIVE_PURCHASE_ORDERS" user_setting=True icon='fa-eye-slash' %} {% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_SALES_ORDERS" user_setting=True icon='fa-truck' %} diff --git a/InvenTree/templates/js/translated/search.js b/InvenTree/templates/js/translated/search.js index 8143487723..b4ce964cc4 100644 --- a/InvenTree/templates/js/translated/search.js +++ b/InvenTree/templates/js/translated/search.js @@ -247,6 +247,22 @@ function updateSearch() { ); } + if (checkPermission('build') && user_settings.SEARCH_PREVIEW_SHOW_BUILD_ORDERS) { + // Search for matching build orders + addSearchQuery( + 'build', + '{% trans "Build Orders" %}', + '{% url "api-build-list" %}', + { + part_detail: true, + }, + renderBuild, + { + url: '/build', + } + ); + } + if ((checkPermission('sales_order') || checkPermission('purchase_order')) && user_settings.SEARCH_PREVIEW_SHOW_COMPANIES) { // Search for matching companies addSearchQuery(