Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Empty order order improvements
Anna Siwik0a5aec82709d
diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.pyindex c78055670c..c24092e9bc 100644--- a/saleor/dashboard/order/forms.py+++ b/saleor/dashboard/order/forms.py@@ -15,12 +15,13 @@ from ...order import OrderStatusfrom ...order.emails import send_note_confirmationfrom ...order.models import Fulfillment, FulfillmentLine, OrderLine, OrderNotefrom ...order.utils import (- add_variant_to_order, change_order_line_quantity, fulfill_order_line,+ add_variant_to_order, change_order_line_quantity,merge_duplicates_into_order_line, recalculate_order, restock_order_lines)from ...product.models import Product, ProductVariant, Stockfrom ...product.utils import allocate_stock, deallocate_stockfrom ..forms import AjaxSelect2ChoiceFieldfrom ..widgets import PhonePrefixWidget+from .utils import fulfill_order_lineclass OrderNoteForm(forms.ModelForm):@@ -112,11 +113,6 @@ class CancelOrderLineForm(forms.Form):deallocate_stock(self.line.stock, self.line.quantity)order = self.line.orderself.line.delete()- if not order.lines.exists():- order.create_history_entry(- content=pgettext_lazy(- 'Order status history entry',- 'Order cancelled. No items in order'))recalculate_order(order)diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex c34706deea..271186e470 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -3,10 +3,7 @@ from functools import wrapsfrom django.conf import settingsfrom django.db.models import Ffrom django.shortcuts import get_object_or_404, redirect-from django.utils.translation import pgettext_lazy-from prices import Money, TaxedMoney, fixed_discount-from . import GroupStatusfrom ..account.utils import store_user_addressfrom ..core.exceptions import InsufficientStockfrom ..product.utils import allocate_stock, deallocate_stock, increase_stockdiff --git a/templates/dashboard/order/detail.html b/templates/dashboard/order/detail.htmlindex 891e15d045..c9c7eecfb3 100644--- a/templates/dashboard/order/detail.html+++ b/templates/dashboard/order/detail.html@@ -330,7 +330,7 @@</div>{% if perms.order.edit_order and order.can_edit or order.can_fulfill %}<div class="data-table-action">- {% if order.can_fulfill %}+ {% if order.can_fulfill and order.get_total_quantity %}<a href="{% url 'dashboard:fulfill-order-lines' order_pk=order.pk %}" class="btn-flat waves-effect" title="{% trans "Fulfill order" context "Order summary card action title" %}">{% trans "Fulfill" context "Order summary card action" %}</a>diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.pyindex 31c5091f86..8b2d995c8e 100644--- a/tests/dashboard/test_order.py+++ b/tests/dashboard/test_order.py@@ -10,8 +10,7 @@ from tests.utils import get_redirect_location, get_url_pathfrom saleor.dashboard.order.forms import ChangeQuantityForm, OrderNoteFormfrom saleor.dashboard.order.utils import fulfill_order_line-from saleor.order.models import (- Fulfillment, Order, OrderHistoryEntry, OrderLine, OrderNote)+from saleor.order.models import Order, OrderHistoryEntry, OrderLine, OrderNotefrom saleor.order.utils import (add_variant_to_existing_lines, add_variant_to_order,change_order_line_quantity)@@ -213,9 +212,7 @@ def test_ordered_item_change_quantity(transactional_db, order_with_lines):change_order_line_quantity(lines[2], 0)change_order_line_quantity(lines[1], 0)change_order_line_quantity(lines[0], 0)- history = list(order_with_lines.history.all())- assert len(history) == 1- assert history[0].content == 'Order cancelled. No items in order'+ assert order_with_lines.get_total_quantity() == 0@pytest.mark.integration