mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #3038 from SchrodingersGat/search-results-fix
Search Results Fix
This commit is contained in:
commit
620dca09a4
@ -1429,6 +1429,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'SEARCH_HIDE_INACTIVE_PARTS': {
|
||||||
|
'name': _("Hide Inactive Parts"),
|
||||||
|
'description': _('Excluded inactive parts from search preview window'),
|
||||||
|
'default': False,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
|
|
||||||
'SEARCH_PREVIEW_SHOW_CATEGORIES': {
|
'SEARCH_PREVIEW_SHOW_CATEGORIES': {
|
||||||
'name': _('Search Categories'),
|
'name': _('Search Categories'),
|
||||||
'description': _('Display part categories in search preview window'),
|
'description': _('Display part categories in search preview window'),
|
||||||
@ -1443,6 +1450,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'SEARCH_PREVIEW_HIDE_UNAVAILABLE_STOCK': {
|
||||||
|
'name': _('Hide Unavailable Stock Items'),
|
||||||
|
'description': _('Exclude stock items which are not available from the search preview window'),
|
||||||
|
'validator': bool,
|
||||||
|
'default': False,
|
||||||
|
},
|
||||||
|
|
||||||
'SEARCH_PREVIEW_SHOW_LOCATIONS': {
|
'SEARCH_PREVIEW_SHOW_LOCATIONS': {
|
||||||
'name': _('Search Locations'),
|
'name': _('Search Locations'),
|
||||||
'description': _('Display stock locations in search preview window'),
|
'description': _('Display stock locations in search preview window'),
|
||||||
@ -1464,6 +1478,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'SEARCH_PREVIEW_EXCLUDE_INACTIVE_PURCHASE_ORDERS': {
|
||||||
|
'name': _('Exclude Inactive Purchase Orders'),
|
||||||
|
'description': _('Exclude inactive purchase orders from search preview window'),
|
||||||
|
'default': True,
|
||||||
|
'validator': bool,
|
||||||
|
},
|
||||||
|
|
||||||
'SEARCH_PREVIEW_SHOW_SALES_ORDERS': {
|
'SEARCH_PREVIEW_SHOW_SALES_ORDERS': {
|
||||||
'name': _('Search Sales Orders'),
|
'name': _('Search Sales Orders'),
|
||||||
'description': _('Display sales orders in search preview window'),
|
'description': _('Display sales orders in search preview window'),
|
||||||
@ -1471,6 +1492,13 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'validator': bool,
|
'validator': bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'SEARCH_PREVIEW_EXCLUDE_INACTIVE_SALES_ORDERS': {
|
||||||
|
'name': _('Exclude Inactive Sales Orders'),
|
||||||
|
'description': _('Exclude inactive sales orders from search preview window'),
|
||||||
|
'validator': bool,
|
||||||
|
'default': True,
|
||||||
|
},
|
||||||
|
|
||||||
'SEARCH_PREVIEW_RESULTS': {
|
'SEARCH_PREVIEW_RESULTS': {
|
||||||
'name': _('Search Preview Results'),
|
'name': _('Search Preview Results'),
|
||||||
'description': _('Number of results to show in each section of the search preview window'),
|
'description': _('Number of results to show in each section of the search preview window'),
|
||||||
@ -1478,13 +1506,6 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
|
|||||||
'validator': [int, MinValueValidator(1)]
|
'validator': [int, MinValueValidator(1)]
|
||||||
},
|
},
|
||||||
|
|
||||||
'SEARCH_HIDE_INACTIVE_PARTS': {
|
|
||||||
'name': _("Hide Inactive Parts"),
|
|
||||||
'description': _('Hide inactive parts in search preview window'),
|
|
||||||
'default': False,
|
|
||||||
'validator': bool,
|
|
||||||
},
|
|
||||||
|
|
||||||
'PART_SHOW_QUANTITY_IN_FORMS': {
|
'PART_SHOW_QUANTITY_IN_FORMS': {
|
||||||
'name': _('Show Quantity in Forms'),
|
'name': _('Show Quantity in Forms'),
|
||||||
'description': _('Display available part quantity in some forms'),
|
'description': _('Display available part quantity in some forms'),
|
||||||
|
@ -163,10 +163,19 @@ class SettingsTest(TestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
for key, setting in InvenTreeSetting.SETTINGS.items():
|
for key, setting in InvenTreeSetting.SETTINGS.items():
|
||||||
self.run_settings_check(key, setting)
|
|
||||||
|
try:
|
||||||
|
self.run_settings_check(key, setting)
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"run_settings_check failed for global setting '{key}'")
|
||||||
|
raise exc
|
||||||
|
|
||||||
for key, setting in InvenTreeUserSetting.SETTINGS.items():
|
for key, setting in InvenTreeUserSetting.SETTINGS.items():
|
||||||
self.run_settings_check(key, setting)
|
try:
|
||||||
|
self.run_settings_check(key, setting)
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"run_settings_check failed for user setting '{key}'")
|
||||||
|
raise exc
|
||||||
|
|
||||||
def test_defaults(self):
|
def test_defaults(self):
|
||||||
"""
|
"""
|
||||||
|
@ -15,16 +15,19 @@
|
|||||||
<table class='table table-striped table-condensed'>
|
<table class='table table-striped table-condensed'>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_PARTS" user_setting=True icon='fa-shapes' %}
|
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_PARTS" user_setting=True icon='fa-shapes' %}
|
||||||
|
{% include "InvenTree/settings/setting.html" with key="SEARCH_HIDE_INACTIVE_PARTS" user_setting=True icon='fa-eye-slash' %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_CATEGORIES" user_setting=True icon='fa-sitemap' %}
|
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_CATEGORIES" user_setting=True icon='fa-sitemap' %}
|
||||||
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_STOCK" user_setting=True icon='fa-boxes' %}
|
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_STOCK" user_setting=True icon='fa-boxes' %}
|
||||||
|
{% 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_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_COMPANIES" user_setting=True icon='fa-building' %}
|
||||||
{% 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_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' %}
|
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_SALES_ORDERS" user_setting=True icon='fa-truck' %}
|
||||||
|
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_EXCLUDE_INACTIVE_SALES_ORDERS" user_setting=True icon='fa-eye-slash' %}
|
||||||
|
|
||||||
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_RESULTS" user_setting=True icon='fa-search' %}
|
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_RESULTS" user_setting=True icon='fa-search' %}
|
||||||
|
|
||||||
{% include "InvenTree/settings/setting.html" with key="SEARCH_HIDE_INACTIVE_PARTS" user_setting=True icon='fa-eye-slash' %}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -122,14 +122,22 @@ function updateSearch() {
|
|||||||
|
|
||||||
if (user_settings.SEARCH_PREVIEW_SHOW_STOCK) {
|
if (user_settings.SEARCH_PREVIEW_SHOW_STOCK) {
|
||||||
// Search for matching stock items
|
// Search for matching stock items
|
||||||
|
|
||||||
|
var filters = {
|
||||||
|
part_detail: true,
|
||||||
|
location_detail: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (user_settings.SEARCH_PREVIEW_HIDE_UNAVAILABLE_STOCK) {
|
||||||
|
// Only show 'in stock' items in the preview windoww
|
||||||
|
filters.in_stock = true;
|
||||||
|
}
|
||||||
|
|
||||||
addSearchQuery(
|
addSearchQuery(
|
||||||
'stock',
|
'stock',
|
||||||
'{% trans "Stock Items" %}',
|
'{% trans "Stock Items" %}',
|
||||||
'{% url "api-stock-list" %}',
|
'{% url "api-stock-list" %}',
|
||||||
{
|
filters,
|
||||||
part_detail: true,
|
|
||||||
location_detail: true,
|
|
||||||
},
|
|
||||||
renderStockItem,
|
renderStockItem,
|
||||||
{
|
{
|
||||||
url: '/stock/item',
|
url: '/stock/item',
|
||||||
@ -167,15 +175,21 @@ function updateSearch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user_settings.SEARCH_PREVIEW_SHOW_PURCHASE_ORDERS) {
|
if (user_settings.SEARCH_PREVIEW_SHOW_PURCHASE_ORDERS) {
|
||||||
|
|
||||||
|
var filters = {
|
||||||
|
supplier_detail: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (user_settings.SEARCH_PREVIEW_EXCLUDE_INACTIVE_PURCHASE_ORDERS) {
|
||||||
|
filters.outstanding = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Search for matching purchase orders
|
// Search for matching purchase orders
|
||||||
addSearchQuery(
|
addSearchQuery(
|
||||||
'purchaseorder',
|
'purchaseorder',
|
||||||
'{% trans "Purchase Orders" %}',
|
'{% trans "Purchase Orders" %}',
|
||||||
'{% url "api-po-list" %}',
|
'{% url "api-po-list" %}',
|
||||||
{
|
filters,
|
||||||
supplier_detail: true,
|
|
||||||
outstanding: true,
|
|
||||||
},
|
|
||||||
renderPurchaseOrder,
|
renderPurchaseOrder,
|
||||||
{
|
{
|
||||||
url: '/order/purchase-order',
|
url: '/order/purchase-order',
|
||||||
@ -184,15 +198,22 @@ function updateSearch() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user_settings.SEARCH_PREVIEW_SHOW_SALES_ORDERS) {
|
if (user_settings.SEARCH_PREVIEW_SHOW_SALES_ORDERS) {
|
||||||
|
|
||||||
|
var filters = {
|
||||||
|
customer_detail: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Hide inactive (not "outstanding" orders)
|
||||||
|
if (user_settings.SEARCH_PREVIEW_EXCLUDE_INACTIVE_SALES_ORDERS) {
|
||||||
|
filters.outstanding = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Search for matching sales orders
|
// Search for matching sales orders
|
||||||
addSearchQuery(
|
addSearchQuery(
|
||||||
'salesorder',
|
'salesorder',
|
||||||
'{% trans "Sales Orders" %}',
|
'{% trans "Sales Orders" %}',
|
||||||
'{% url "api-so-list" %}',
|
'{% url "api-so-list" %}',
|
||||||
{
|
filters,
|
||||||
customer_detail: true,
|
|
||||||
outstanding: true,
|
|
||||||
},
|
|
||||||
renderSalesOrder,
|
renderSalesOrder,
|
||||||
{
|
{
|
||||||
url: '/order/sales-order',
|
url: '/order/sales-order',
|
||||||
|
Loading…
Reference in New Issue
Block a user