From 8c9202de213e513e11a1c229489fdfe234a0c98e Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 23 Feb 2021 15:40:31 +1100 Subject: [PATCH] Bug fix for label / report filtering --- InvenTree/label/api.py | 19 ++++++------------- InvenTree/report/api.py | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/InvenTree/label/api.py b/InvenTree/label/api.py index a4800cd5d9..e303f493c6 100644 --- a/InvenTree/label/api.py +++ b/InvenTree/label/api.py @@ -122,13 +122,9 @@ class StockItemLabelMixin: params = self.request.query_params - if 'items[]' in params: - items = params.getlist('items[]', []) - elif 'item' in params: - items = [params.get('item', None)] - - if type(items) not in [list, tuple]: - items = [items] + for key in ['item', 'item[]', 'items', 'items[]']: + if key in params: + items = params.getlist(key, []) valid_ids = [] @@ -258,13 +254,10 @@ class StockLocationLabelMixin: params = self.request.query_params - if 'locations[]' in params: - locations = params.getlist('locations[]', []) - elif 'location' in params: - locations = [params.get('location', None)] + for key in ['location', 'location[]', 'locations', 'locations[]']: - if type(locations) not in [list, tuple]: - locations = [locations] + if key in params: + locations = params.getlist(key, []) valid_ids = [] diff --git a/InvenTree/report/api.py b/InvenTree/report/api.py index 09bd9fde8f..313d4de88d 100644 --- a/InvenTree/report/api.py +++ b/InvenTree/report/api.py @@ -62,7 +62,10 @@ class StockItemReportMixin: params = self.request.query_params - items = params.getlist('item', []) + for key in ['item', 'item[]', 'items', 'items[]']: + if key in params: + items = params.getlist(key, []) + break valid_ids = [] @@ -92,7 +95,12 @@ class BuildReportMixin: params = self.request.query_params - builds = params.getlist('build', []) + for key in ['build', 'build[]', 'builds', 'builds[]']: + + if key in params: + builds = params.getlist(key, []) + + break valid_ids = [] @@ -119,7 +127,10 @@ class PartReportMixin: params = self.request.query_params - parts = params.getlist('part', []) + for key in ['part', 'part[]', 'parts', 'parts[]']: + + if key in params: + parts = params.getlist(key, []) valid_ids = []