From 4ff1c690cc4db88b9a2cbdad3a04db2b1f818fb1 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 12:33:01 +1100 Subject: [PATCH 1/7] Bug fix for paginated tables --- InvenTree/templates/js/tables.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/InvenTree/templates/js/tables.js b/InvenTree/templates/js/tables.js index f09c683bff..21e673d5ed 100644 --- a/InvenTree/templates/js/tables.js +++ b/InvenTree/templates/js/tables.js @@ -145,10 +145,7 @@ $.fn.inventreeTable = function(options) { var filters = options.queryParams || options.filters || {}; options.queryParams = function(params) { - for (var key in filters) { - params[key] = filters[key]; - } - + // Override the way that we ask the server to sort results // It seems bootstrap-table does not offer a "native" way to do this... if ('sort' in params) { @@ -170,6 +167,15 @@ $.fn.inventreeTable = function(options) { } + for (var key in filters) { + params[key] = filters[key]; + } + + // Add "order" back in (if it was originally specified by InvenTree) + // Annoyingly, "order" shadows some field names in InvenTree... + if ('order' in filters) { + params['order'] = filters['order']; + } return params; } From 1c3b017283129c6c8b5160cf17a76794fed0eb30 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 12:33:41 +1100 Subject: [PATCH 2/7] Improve server-side pagination of SalesOrderLineItem --- InvenTree/order/api.py | 18 +++++++++++++++++- .../templates/order/sales_order_detail.html | 3 ++- InvenTree/stock/api.py | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index ce75a47697..33937acc94 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -412,7 +412,23 @@ class SOLineItemList(generics.ListCreateAPIView): return queryset - filter_backends = [DjangoFilterBackend] + filter_backends = [ + DjangoFilterBackend, + filters.SearchFilter, + filters.OrderingFilter + ] + + ordering_fields = [ + 'part__name', + 'quantity', + 'reference', + ] + + search_fields = [ + 'part__name', + 'quantity', + 'reference', + ] filter_fields = [ 'order', diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index c91cc6e51b..27bbd542dd 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -173,6 +173,7 @@ $("#so-lines-table").inventreeTable({ part_detail: true, allocations: true, }, + sidePagination: 'server', uniqueId: 'pk', url: "{% url 'api-so-line-list' %}", onPostBody: setupCallbacks, @@ -201,6 +202,7 @@ $("#so-lines-table").inventreeTable({ }, { sortable: true, + sortName: 'part__name', field: 'part', title: 'Part', formatter: function(value, row, index, field) { @@ -222,7 +224,6 @@ $("#so-lines-table").inventreeTable({ title: 'Quantity', }, { - sortable: true, field: 'allocated', {% if order.status == SalesOrderStatus.PENDING %} title: '{% trans "Allocated" %}', diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 15edfed066..60e511616a 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -853,7 +853,9 @@ class StockList(generics.ListCreateAPIView): 'status', ] - ordering = ['part__name'] + ordering = [ + 'part__name' + ] search_fields = [ 'serial', From 6f4178acdb5cc9c54d5f0106dbc45b63af433347 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 12:38:37 +1100 Subject: [PATCH 3/7] Improve server-side pagination for POLineItem --- InvenTree/order/api.py | 16 ++++++++++++++++ .../templates/order/purchase_order_detail.html | 12 ++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index 33937acc94..95644199c5 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -200,6 +200,22 @@ class POLineItemList(generics.ListCreateAPIView): filter_backends = [ DjangoFilterBackend, + filters.SearchFilter, + filters.OrderingFilter + ] + + ordering_fields = [ + 'part__part__name', + 'part__MPN', + 'part__SKU', + 'reference', + 'quantity', + 'received', + ] + + search_Fields = [ + 'part__part__name', + 'part__part__description', ] filter_fields = [ diff --git a/InvenTree/order/templates/order/purchase_order_detail.html b/InvenTree/order/templates/order/purchase_order_detail.html index 268e83ef4e..b22d045258 100644 --- a/InvenTree/order/templates/order/purchase_order_detail.html +++ b/InvenTree/order/templates/order/purchase_order_detail.html @@ -135,6 +135,7 @@ function setupCallbacks() { $("#po-table").inventreeTable({ onPostBody: setupCallbacks, name: 'purchaseorder', + sidePagination: 'server', formatNoMatches: function() { return "{% trans 'No line items found' %}"; }, queryParams: { order: {{ order.id }}, @@ -151,6 +152,7 @@ $("#po-table").inventreeTable({ { field: 'part', sortable: true, + sortName: 'part__part__name', title: '{% trans "Part" %}', switchable: false, formatter: function(value, row, index, field) { @@ -162,18 +164,24 @@ $("#po-table").inventreeTable({ }, }, { - sortable: true, field: 'part_detail.description', title: '{% trans "Description" %}', }, { sortable: true, + sortName: 'part__SKU', field: 'supplier_part_detail.SKU', - title: '{% trans "Order Code" %}', + title: '{% trans "SKU" %}', formatter: function(value, row, index, field) { return renderLink(value, `/supplier-part/${row.part}/`); }, }, + { + sortable: true, + sortName: 'part__MPN', + field: 'supplier_part_detail.MPN', + title: '{% trans "MPN" %}', + }, { sortable: true, field: 'reference', From 628e87cb28751dab4fb3709a930fa8e33cdb84e9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 13:08:12 +1100 Subject: [PATCH 4/7] search field fixes --- InvenTree/order/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index 95644199c5..db4c4dcc50 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -213,9 +213,12 @@ class POLineItemList(generics.ListCreateAPIView): 'received', ] - search_Fields = [ + search_fields = [ 'part__part__name', 'part__part__description', + 'part__MPN', + 'part__SKU', + 'reference', ] filter_fields = [ From 2cf87c1c3030699289d8f7bc9639849bb549cabf Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 14:05:52 +1100 Subject: [PATCH 5/7] Adds body styling to label base --- InvenTree/label/templates/label/label_base.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/InvenTree/label/templates/label/label_base.html b/InvenTree/label/templates/label/label_base.html index 2c564d1132..2986c8a439 100644 --- a/InvenTree/label/templates/label/label_base.html +++ b/InvenTree/label/templates/label/label_base.html @@ -10,6 +10,11 @@ {% endblock %} } + body { + font-family: Arial, Helvetica, sans-serif; + margin: 0mm; + } + img { display: inline-block; image-rendering: pixelated; From bc25e795dd3e5eebd34b168a1dc3a924684da6d6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 14:34:20 +1100 Subject: [PATCH 6/7] Shorten git hash --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 872ef0eb0d..93956c35b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,7 @@ script: # Run linting checks on migration files (django-migration-linter) # Run subset of linting checks on *ALL* migration files # Run strict migration file checks on *NEW* migrations (old ones are what they are) - - cd InvenTree && python manage.py lintmigrations 79ddea50f507e34195bad635008419daac0d7a5f -q ok ignore --no-cache && cd .. + - cd InvenTree && python manage.py lintmigrations 79ddea50 -q ok ignore --no-cache && cd .. after_success: - coveralls \ No newline at end of file From 9478da2ad27e5558d2aabd025a93b03dbbfad95f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 2 Mar 2021 15:53:56 +1100 Subject: [PATCH 7/7] Remove django-migration-linter which was causing strange errors --- .travis.yml | 4 ---- InvenTree/InvenTree/settings.py | 1 - requirements.txt | 1 - 3 files changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 872ef0eb0d..52d0ef1c5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,10 +48,6 @@ script: - rm inventree_default_db.sqlite3 - invoke migrate - invoke import-records -f data.json - # Run linting checks on migration files (django-migration-linter) - # Run subset of linting checks on *ALL* migration files - # Run strict migration file checks on *NEW* migrations (old ones are what they are) - - cd InvenTree && python manage.py lintmigrations 79ddea50f507e34195bad635008419daac0d7a5f -q ok ignore --no-cache && cd .. after_success: - coveralls \ No newline at end of file diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 3abb99010f..1a298240bc 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -211,7 +211,6 @@ INSTALLED_APPS = [ 'djmoney', # django-money integration 'djmoney.contrib.exchange', # django-money exchange rates 'error_report', # Error reporting in the admin interface - 'django_migration_linter', # Linting checking for migration files ] MIDDLEWARE = CONFIG.get('middleware', [ diff --git a/requirements.txt b/requirements.txt index cf05148ebf..7bbc14bd54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -28,7 +28,6 @@ django-money==1.1 # Django app for currency management certifi # Certifi is (most likely) installed through one of the requirements above django-error-report==0.2.0 # Error report viewer for the admin interface django-test-migrations==1.1.0 # Unit testing for database migrations -django-migration-linter==2.5.0 # Linting checks for database migrations python-barcode[images]==0.13.1 # Barcode generator qrcode[pil]==6.1 # QR code generator