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'