diff --git a/InvenTree/templates/js/translated/model_renderers.js b/InvenTree/templates/js/translated/model_renderers.js index 8924687d3c..7be6c954c2 100644 --- a/InvenTree/templates/js/translated/model_renderers.js +++ b/InvenTree/templates/js/translated/model_renderers.js @@ -228,14 +228,12 @@ function renderOwner(name, data, parameters={}, options={}) { // Renderer for "PurchaseOrder" model // eslint-disable-next-line no-unused-vars function renderPurchaseOrder(name, data, parameters={}, options={}) { - var html = ''; var prefix = global_settings.PURCHASEORDER_REFERENCE_PREFIX; + var html = `${prefix}${data.reference}`; var thumbnail = null; - html += `${prefix}${data.reference}`; - if (data.supplier_detail) { thumbnail = data.supplier_detail.thumbnail || data.supplier_detail.image; @@ -262,7 +260,18 @@ function renderPurchaseOrder(name, data, parameters={}, options={}) { // Renderer for "SalesOrder" model // eslint-disable-next-line no-unused-vars function renderSalesOrder(name, data, parameters={}, options={}) { - var html = `${data.reference}`; + + var prefix = global_settings.SALESORDER_REFERENCE_PREFIX; + var html = `${prefix}${data.reference}`; + + var thumbnail = null; + + if (data.customer_detail) { + thumbnail = data.customer_detail.thumbnail || data.customer_detail.image; + + html += ' - ' + select2Thumbnail(thumbnail); + html += `${data.customer_detail.name}`; + } if (data.description) { html += ` - ${data.description}`; diff --git a/InvenTree/templates/js/translated/search.js b/InvenTree/templates/js/translated/search.js index 29b27e4a3f..facfb884ff 100644 --- a/InvenTree/templates/js/translated/search.js +++ b/InvenTree/templates/js/translated/search.js @@ -79,12 +79,19 @@ function updateSearch() { $('#offcanvas-search').find('#search-pending').show(); if (user_settings.SEARCH_PREVIEW_SHOW_PARTS) { + + var params = {}; + + if (user_settings.SEARCH_HIDE_INACTIVE_PARTS) { + params.active = false; + } + // Search for matching parts addSearchQuery( 'part', '{% trans "Parts" %}', '{% url "api-part-list" %}', - {}, + params, renderPart, { url: '/part', @@ -150,6 +157,40 @@ function updateSearch() { } ); } + + if (user_settings.SEARCH_PREVIEW_SHOW_PURCHASE_ORDERS) { + // Search for matching purchase orders + addSearchQuery( + 'purchaseorder', + '{% trans "Purchase Orders" %}', + '{% url "api-po-list" %}', + { + supplier_detail: true, + outstanding: true, + }, + renderPurchaseOrder, + { + url: '/order/purchase-order', + } + ); + } + + if (user_settings.SEARCH_PREVIEW_SHOW_SALES_ORDERS) { + // Search for matching sales orders + addSearchQuery( + 'salesorder', + '{% trans "Sales Orders" %}', + '{% url "api-so-list" %}', + { + customer_detail: true, + outstanding: true, + }, + renderSalesOrder, + { + url: '/order/sales-order', + } + ); + } // Wait until all the pending queries are completed $.when.apply($, searchQueries).done(function() {