From 7a7b0aea332ce10ebf13f034dcf0ee610fdabb8b Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 12 Apr 2019 22:43:22 +1000 Subject: [PATCH 1/2] Changed 'stocklocation.items' to 'stocklocation.stock_items' --- InvenTree/stock/models.py | 6 +++--- InvenTree/stock/templates/stock/location_delete.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index d0f7fd3f38..b020640497 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -27,19 +27,19 @@ class StockLocation(InvenTreeTree): return '/stock/location/{id}/'.format(id=self.id) @property - def items(self): + def stock_items(self): return self.stockitem_set.all() @property def has_items(self): - return self.items.count() > 0 + return self.stock_items.count() > 0 @receiver(pre_delete, sender=StockLocation, dispatch_uid='stocklocation_delete_log') def before_delete_stock_location(sender, instance, using, **kwargs): # Update each part in the stock location - for item in instance.items.all(): + for item in instance.stock_items.all(): item.location = instance.parent item.save() diff --git a/InvenTree/stock/templates/stock/location_delete.html b/InvenTree/stock/templates/stock/location_delete.html index 53cdf2cc27..6c3ee981e5 100644 --- a/InvenTree/stock/templates/stock/location_delete.html +++ b/InvenTree/stock/templates/stock/location_delete.html @@ -19,8 +19,8 @@ the top level 'Stock' location. {% endif %} -{% if location.items.all|length > 0 %} -

This location contains {{ location.items.all|length }} stock items.
+{% if location.stock_items.all|length > 0 %} +

This location contains {{ location.stock_items.all|length }} stock items.
{% if location.parent %} If this location is deleted, these items will be moved to the '{{ location.parent.name }}' location. {% else %} @@ -29,7 +29,7 @@ If this location is deleted, these items will be moved to the top level 'Stock'

From 88103b63d2f8ded8a75ba5ec57c1248a2cc1fc2a Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 12 Apr 2019 22:46:48 +1000 Subject: [PATCH 2/2] Cannot filter by STATUS - Is this because it is a dict? - Need to address this in the future --- InvenTree/stock/api.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 7516824318..d2c1c13805 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -226,7 +226,7 @@ class StockList(generics.ListCreateAPIView): 'supplier_part', 'customer', 'belongs_to', - 'status', + #'status', ] @@ -304,8 +304,6 @@ location_endpoints = [ stock_api_urls = [ - # Detail for a single stock item - url(r'^(?P[0-9]+)/', include(stock_endpoints)), url(r'location/?', StockLocationList.as_view(), name='api-location-list'), @@ -319,5 +317,8 @@ stock_api_urls = [ url(r'^tree/?', StockCategoryTree.as_view(), name='api-stock-tree'), + # Detail for a single stock item + url(r'^(?P\d+)/', include(stock_endpoints)), + url(r'^.*$', StockList.as_view(), name='api-stock-list'), ] \ No newline at end of file