Skip to content

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

Stop removing entire order groups when removing a single line

Patryk Zawadzki1da95fe3b60c
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py
index 06bbcc012f..d818fd1da3 100644
--- a/saleor/dashboard/order/forms.py
+++ b/saleor/dashboard/order/forms.py
@@ -156,7 +156,8 @@ class CancelItemsForm(forms.Form):
if self.item.stock:
Stock.objects.deallocate_stock(self.item.stock, self.item.quantity)
order = self.item.delivery_group.order
- OrderedItem.objects.remove_empty_groups(self.item, force=True)
+ self.item.quantity = 0
+ OrderedItem.objects.remove_empty_groups(self.item)
Order.objects.recalculate_order(order)
diff --git a/templates/dashboard/order/detail.html b/templates/dashboard/order/detail.html
index 224e79fb5f..b377a1138e 100644
--- a/templates/dashboard/order/detail.html
+++ b/templates/dashboard/order/detail.html
@@ -257,8 +257,8 @@
</li>
<li>
<a href="#base-modal" data-href="{% url 'dashboard:orderline-cancel' order_pk=order.pk line_pk=item.pk %}" class="modal-trigger-custom"
- title="{% trans "Cancel line" context "Shipment group table row action" %}">
- {% trans "Cancel line" context "Shipment group table row action" %}
+ title="{% trans "Remove line" context "Shipment group table row action" %}">
+ {% trans "Remove line" context "Shipment group table row action" %}
</a>
</li>
</ul>
diff --git a/templates/dashboard/order/modal_cancel_line.html b/templates/dashboard/order/modal_cancel_line.html
index 7e14429671..ecadab10a3 100644
--- a/templates/dashboard/order/modal_cancel_line.html
+++ b/templates/dashboard/order/modal_cancel_line.html
@@ -5,21 +5,21 @@
<form class="form-async" role="form" method="post" action="{% url 'dashboard:orderline-cancel' order_pk=order.pk line_pk=item.pk %}" novalidate>
{% csrf_token %}
<div class="modal-content">
- <h5>{% trans "Cancel order line?" context "Modal cancel order line title" %}</h5>
+ <h5>{% trans "Remove order line?" context "Modal remove order line title" %}</h5>
<p>
- {% blocktrans trimmed with order=order context "Modal cancel order line text" %}
- Are you sure, you want cancel this order line?
+ {% blocktrans trimmed with order=order context "Modal remove order line text" %}
+ Are you sure you want remove this order line?
{% endblocktrans %}
</p>
{{ form|materializecss }}
<table>
<thead>
<tr>
- <th class="wide">{% trans "Item" context "Modal cancel order line table header" %}</th>
- <th>{% trans "SKU" context "Modal cancel order line table header" %}</th>
- <th class="right-align">{% trans "Price" context "Modal cancel order line table header" %}</th>
- <th class="right-align">{% trans "Quantity" context "Modal cancel order line table header" %}</th>
- <th class="right-align">{% trans "Total" context "Modal cancel order line table header" %}</th>
+ <th class="wide">{% trans "Item" context "Modal remove order line table header" %}</th>
+ <th>{% trans "SKU" context "Modal remove order line table header" %}</th>
+ <th class="right-align">{% trans "Price" context "Modal remove order line table header" %}</th>
+ <th class="right-align">{% trans "Quantity" context "Modal remove order line table header" %}</th>
+ <th class="right-align">{% trans "Total" context "Modal remove order line table header" %}</th>
</tr>
</thead>
<tbody>
@@ -38,8 +38,8 @@
<div class="modal-footer">
<button type="submit" class="modal-action btn-flat">
- {% trans "Cancel Line" context "Modal cancel order line primary action" %}</button>
+ {% trans "Remove" context "Modal remove order line primary action" %}</button>
<a href="#!" aria-hidden="true" class="modal-action modal-close btn-flat">
- {% trans "Abort" context "Modal cancel order line secondary action" %}</a>
+ {% trans "Cancel" context "Modal remove order line secondary action" %}</a>
</div>
</form>