From 14000517ce7c57ef12ec95c8c45246870f38b17a Mon Sep 17 00:00:00 2001
From: Oliver Walters <oliver.henry.walters@gmail.com>
Date: Wed, 3 Mar 2021 08:39:14 +1100
Subject: [PATCH] Fixes for build order table

---
 InvenTree/build/api.py            | 16 ++++++++++++++++
 InvenTree/templates/js/build.js   |  2 +-
 InvenTree/templates/js/company.js |  1 -
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py
index cb6b3f6b2b..175f39ba63 100644
--- a/InvenTree/build/api.py
+++ b/InvenTree/build/api.py
@@ -38,6 +38,22 @@ class BuildList(generics.ListCreateAPIView):
         'sales_order',
     ]
 
+    ordering_fields = [
+        'reference',
+        'part__name',
+        'status',
+        'creation_date',
+        'target_date',
+        'completion_date',
+        'quantity',
+    ]
+
+    search_fields = [
+        'reference',
+        'part__name',
+        'description',
+    ]
+
     def get_queryset(self):
         """
         Override the queryset filtering,
diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js
index 45ebd133d1..daa78748a4 100644
--- a/InvenTree/templates/js/build.js
+++ b/InvenTree/templates/js/build.js
@@ -671,12 +671,12 @@ function loadBuildTable(table, options) {
             {
                 field: 'title',
                 title: '{% trans "Description" %}',
-                sortable: true,
             },
             {
                 field: 'part',
                 title: '{% trans "Part" %}',
                 sortable: true,
+                sortName: 'part__name',
                 formatter: function(value, row, index, field) {
 
                     var html = imageHoverIcon(row.part_detail.thumbnail);
diff --git a/InvenTree/templates/js/company.js b/InvenTree/templates/js/company.js
index b497609db1..601d4a5370 100644
--- a/InvenTree/templates/js/company.js
+++ b/InvenTree/templates/js/company.js
@@ -54,7 +54,6 @@ function loadCompanyTable(table, url, options={}) {
         {
             field: 'description',
             title: '{% trans "Description" %}',
-            sortable: true,
         },
         {
             field: 'website',