2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-29 20:16:44 +00:00

Override the "delete" behaviour for StockItem API

- Mark for deletion instead of calling database delete
- Returns (almost) instantly instead of hanging
- Much better UI experience when performing bulk delete operations
This commit is contained in:
Oliver 2021-09-28 10:14:25 +10:00
parent b623f34881
commit 16e00962f5

View File

@ -109,6 +109,17 @@ class StockDetail(generics.RetrieveUpdateDestroyAPIView):
return super().update(request, *args, **kwargs)
def perform_destroy(self, instance):
"""
Instead of "deleting" the StockItem
(which may take a long time)
we instead schedule it for deletion at a later date.
The background worker will delete these in the future
"""
instance.mark_for_deletion()
class StockAdjust(APIView):
"""