Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add can edit items method to delivery group
Anna Siwik86df2374b4fa
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex 534d238004..ae3f346a96 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -203,6 +203,7 @@ class ChangeQuantityForm(forms.ModelForm):# update stock allocationdelta = quantity - self.initial_quantityStock.objects.allocate_stock(stock, delta)+ stock.refresh_from_db()self.instance.change_quantity(quantity)Order.objects.recalculate_order(self.instance.delivery_group.order)diff --git a/saleor/order/models.py b/saleor/order/models.pyindex 5b30f69f5b..3b93f7eb38 100644--- a/saleor/order/models.py+++ b/saleor/order/models.py@@ -294,6 +294,9 @@ class DeliveryGroup(models.Model, ItemSet):def can_cancel(self):return self.status != OrderStatus.CANCELLED+ def can_edit_items(self):+ return self.status not in {OrderStatus.CANCELLED, OrderStatus.SHIPPED}+class OrderedItemManager(models.Manager):def move_to_group(self, item, target_group, quantity):diff --git a/templates/dashboard/order/detail.html b/templates/dashboard/order/detail.htmlindex 87b07339aa..0195f8ecd7 100644--- a/templates/dashboard/order/detail.html+++ b/templates/dashboard/order/detail.html@@ -308,7 +308,7 @@{{ item.product_name }}<br></td><td class="right-align">- {% if group.status != 'cancelled' %}+ {% if group.can_edit_items %}<a class="dropdown-button" href="#" data-activates="line-stock-actions-{{ item.pk }}" data-constrainwidth="false">{{ item.stock_location|default:"-" }}<svg data-src="{% static "dashboard/images/arrow_drop_down.svg" %}" width="24" height="24" />@@ -331,7 +331,7 @@{% gross item.get_price_per_item html=True %}</td><td class="right-align">- {% if group.status != 'cancelled' %}+ {% if group.can_edit_items %}<a class="dropdown-button" href="#" data-activates="line-actions-{{ item.pk }}" data-constrainwidth="false">{{ item.quantity }}<svg data-src="{% static "dashboard/images/arrow_drop_down.svg" %}" width="24" height="24" />