mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Adds option to hide unavailable stock items from the search preview window
This commit is contained in:
		| @@ -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'), | ||||||
| @@ -1479,7 +1493,7 @@ class InvenTreeUserSetting(BaseInvenTreeSetting): | |||||||
|         }, |         }, | ||||||
|  |  | ||||||
|         'SEARCH_PREVIEW_EXCLUDE_INACTIVE_SALES_ORDERS': { |         'SEARCH_PREVIEW_EXCLUDE_INACTIVE_SALES_ORDERS': { | ||||||
|             'name': 'Exclude Inactive Sales Orders', |             'name': _('Exclude Inactive Sales Orders'), | ||||||
|             'description': _('Exclude inactive sales orders from search preview window'), |             'description': _('Exclude inactive sales orders from search preview window'), | ||||||
|             'validator': bool, |             'validator': bool, | ||||||
|             'default': True, |             'default': True, | ||||||
| @@ -1492,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'), | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
|             {% 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_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' %} | ||||||
|   | |||||||
| @@ -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', | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user