From 86b3092b5e20528216f1161268988eb4cf3d04e6 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 16 Apr 2018 23:28:53 +1000 Subject: [PATCH] Change action on deleting top-level stock location --- InvenTree/stock/models.py | 9 ++------- InvenTree/stock/templates/stock/location_delete.html | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index b48514976b..4728964e1e 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -38,13 +38,8 @@ def before_delete_stock_location(sender, instance, using, **kwargs): # Update each part in the stock location for item in instance.items.all(): - # If this location has a parent, move the child stock items to the parent - if instance.parent: - item.location = instance.parent - item.save() - # No parent location? Delete the stock items - else: - item.delete() + item.location = instance.parent + item.save() # Update each child category for child in instance.children.all(): diff --git a/InvenTree/stock/templates/stock/location_delete.html b/InvenTree/stock/templates/stock/location_delete.html index 135ed55d51..5bdd5249f6 100644 --- a/InvenTree/stock/templates/stock/location_delete.html +++ b/InvenTree/stock/templates/stock/location_delete.html @@ -11,7 +11,7 @@ If this location is deleted, these child locations will be moved to {% if location.parent %} the '{{ location.parent.name }}' location. {% else %} -the top level 'Stock' category. +the top level 'Stock' location. {% endif %}

@@ -27,7 +27,7 @@ the top level 'Stock' category. {% if location.parent %} If this location is deleted, these items will be moved to the '{{ location.parent.name }}' location. {% else %} -If this location is deleted, these items will be deleted! +If this location is deleted, these items will be moved to the top level 'Stock' location. {% endif %}