Change action on deleting top-level stock location

This commit is contained in:
Oliver 2018-04-16 23:28:53 +10:00
parent 937470750b
commit 86b3092b5e
2 changed files with 4 additions and 9 deletions

View File

@ -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():

View File

@ -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 %}
</p>
@ -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 %}
</p>