Search improvements (#3103)

* Allow part list API to be searched by SKU

* Enable manufacturer parts and supplier parts search preview

* Increment API version

* Remove whitespace

* Remove more whitespace
This commit is contained in:
Oliver 2022-05-31 11:51:22 +10:00 committed by GitHub
parent ccefefdc7f
commit 02607bd854
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 1 deletions

View File

@ -4,11 +4,14 @@ InvenTree API version information
# InvenTree API version
INVENTREE_API_VERSION = 51
INVENTREE_API_VERSION = 52
"""
Increment this API version number whenever there is a significant change to the API that any clients need to know about
v52 -> 2022-05-31 : https://github.com/inventree/InvenTree/pull/3103
- Allow part list API to be searched by supplier SKU
v51 -> 2022-05-24 : https://github.com/inventree/InvenTree/pull/3058
- Adds new fields to the SalesOrderShipment model

View File

@ -1425,6 +1425,20 @@ class InvenTreeUserSetting(BaseInvenTreeSetting):
'validator': bool,
},
'SEARCH_PREVIEW_SHOW_SUPPLIER_PARTS': {
'name': _('Seach Supplier Parts'),
'description': _('Display supplier parts in search preview window'),
'default': True,
'validator': bool,
},
'SEARCH_PREVIEW_SHOW_MANUFACTURER_PARTS': {
'name': _('Search Manufacturer Parts'),
'description': _('Display manufacturer parts in search preview window'),
'default': True,
'validator': bool,
},
'SEARCH_HIDE_INACTIVE_PARTS': {
'name': _("Hide Inactive Parts"),
'description': _('Excluded inactive parts from search preview window'),

View File

@ -1387,6 +1387,7 @@ class PartList(APIDownloadMixin, generics.ListCreateAPIView):
'keywords',
'category__name',
'manufacturer_parts__MPN',
'supplier_parts__SKU',
]

View File

@ -16,6 +16,8 @@
<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_HIDE_INACTIVE_PARTS" user_setting=True icon='fa-eye-slash' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_SUPPLIER_PARTS" user_setting=True icon='fa-building' %}
{% include "InvenTree/settings/setting.html" with key="SEARCH_PREVIEW_SHOW_MANUFACTURER_PARTS" user_setting=True icon='fa-industry' %}
{% 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_HIDE_UNAVAILABLE_STOCK" user_setting=True icon='fa-eye-slash' %}

View File

@ -151,6 +151,46 @@ function updateSearch() {
);
}
if (checkPermission('part') && checkPermission('purchase_order')) {
var params = {
part_detail: true,
supplier_detail: true,
manufacturer_detail: true,
};
if (user_settings.SEARCH_HIDE_INACTIVE_PARTS) {
// Return *only* active parts
params.active = true;
}
if (user_settings.SEARCH_PREVIEW_SHOW_SUPPLIER_PARTS) {
addSearchQuery(
'supplierpart',
'{% trans "Supplier Parts" %}',
'{% url "api-supplier-part-list" %}',
params,
renderSupplierPart,
{
url: '/supplier-part',
}
);
}
if (user_settings.SEARCH_PREVIEW_SHOW_MANUFACTURER_PARTS) {
addSearchQuery(
'manufacturerpart',
'{% trans "Manufacturer Parts" %}',
'{% url "api-manufacturer-part-list" %}',
params,
renderManufacturerPart,
{
url: '/manufacturer-part',
}
);
}
}
if (checkPermission('part_category') && user_settings.SEARCH_PREVIEW_SHOW_CATEGORIES) {
// Search for matching part categories
addSearchQuery(