mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improve filtering for stock items
This commit is contained in:
parent
011f5a5efd
commit
e278bdbb90
@ -6,10 +6,9 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
|
|
||||||
<b>Stock Items</b>
|
|
||||||
<table class='table table-condensed table-striped' id='stock-table'>
|
<table class='table table-condensed table-striped' id='stock-table'>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Item</th>
|
<th>Stock Item</th>
|
||||||
<th>Location</th>
|
<th>Location</th>
|
||||||
<th>{{ stock_action }}</th>
|
<th>{{ stock_action }}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
@ -135,15 +135,14 @@ class StockItemMoveMultiple(AjaxView, FormMixin):
|
|||||||
stock_items = []
|
stock_items = []
|
||||||
|
|
||||||
def get_items(self, item_list):
|
def get_items(self, item_list):
|
||||||
""" Return list of stock items. """
|
""" Return list of stock items initally requested using GET """
|
||||||
|
|
||||||
items = []
|
# Start with all 'in stock' items
|
||||||
|
items = StockItem.objects.filter(customer=None, belongs_to=None)
|
||||||
|
|
||||||
for pk in item_list:
|
# Client provides a list of individual stock items
|
||||||
try:
|
if 'stock[]' in self.request.GET:
|
||||||
items.append(StockItem.objects.get(pk=pk))
|
items = items.filter(id__in=self.request.GET.getlist('stock[]'))
|
||||||
except StockItem.DoesNotExist:
|
|
||||||
pass
|
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
|
||||||
@ -166,6 +165,8 @@ class StockItemMoveMultiple(AjaxView, FormMixin):
|
|||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
|
||||||
|
self.request = request
|
||||||
|
|
||||||
# Save list of items!
|
# Save list of items!
|
||||||
self.stock_items = self.get_items(request.GET.getlist('stock[]'))
|
self.stock_items = self.get_items(request.GET.getlist('stock[]'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user