Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Warning about stocks that will be deleted with stock location

Mira Szewczykcad23988fb87
diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.py
index 373ada0e96..ad0cb7acfe 100644
--- a/saleor/dashboard/product/views.py
+++ b/saleor/dashboard/product/views.py
@@ -304,12 +304,13 @@ def stock_location_edit(request, location_pk=None):
@staff_member_required
def stock_location_delete(request, location_pk):
location = get_object_or_404(StockLocation, pk=location_pk)
+ stock_count = location.stock_set.count()
if request.method == 'POST':
location.delete()
messages.success(
request, _('Deleted location %s') % location)
return redirect('dashboard:product-stock-location-list')
- ctx = {'location': location}
+ ctx = {'location': location, 'stock_count': stock_count}
return TemplateResponse(
request, 'dashboard/product/stock_locations/modal_confirm_delete.html',
ctx)
diff --git a/templates/dashboard/product/stock_locations/modal_confirm_delete.html b/templates/dashboard/product/stock_locations/modal_confirm_delete.html
index 435f7cd4e7..e734716fd2 100644
--- a/templates/dashboard/product/stock_locations/modal_confirm_delete.html
+++ b/templates/dashboard/product/stock_locations/modal_confirm_delete.html
@@ -5,9 +5,21 @@
<div class="modal-content">
<h5>{% trans "Are you sure?" %}</h5>
- <p>
- {% blocktrans %}You are about to delete a stock location <strong>{{ location }}</strong>.{% endblocktrans %}
- </p>
+ <div class="row">
+ <div class="col l12">
+ {% blocktrans %}
+ You are about to delete a stock location <strong>{{ location }}</strong>.
+ {% endblocktrans %}
+ </div>
+ </div>
+
+ {% if stock_count %}
+ {% blocktrans count counter=stock_count %}
+ There is one stock associated with this stock location that will be deleted.
+ {% plural %}
+ There are {{ stock_count }} stocks associated with this stock_location that will be deleted.
+ {% endblocktrans %}
+ {% endif %}
</div>
<div class="modal-footer">