Skip to content

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

Fix issues from latest commit

NyanKiyoshi251bd5f2fc12
diff --git a/saleor/checkout/views/summary.py b/saleor/checkout/views/summary.py
index c900765289..dab7c4332c 100644
--- a/saleor/checkout/views/summary.py
+++ b/saleor/checkout/views/summary.py
@@ -8,11 +8,10 @@ from ...core.exceptions import InsufficientStock
from ...discount.models import NotApplicable
from ..forms import CheckoutNoteForm
from ..utils import (
- get_checkout_context, get_taxes_for_checkout,
+ get_checkout_context, get_taxes_for_checkout, place_checkout_to_order,
update_billing_address_in_anonymous_checkout,
update_billing_address_in_checkout,
- update_billing_address_in_checkout_with_shipping,
- place_checkout_to_order)
+ update_billing_address_in_checkout_with_shipping)
def handle_order_placement(request, checkout):
diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.py
index 666b7e4e7b..ac6876c8f1 100644
--- a/saleor/dashboard/order/views.py
+++ b/saleor/dashboard/order/views.py
@@ -170,8 +170,9 @@ def capture_payment(request, order_pk, payment_pk):
msg = pgettext_lazy(
'Dashboard message related to a payment',
'Captured %(amount)s') % {'amount': prices_i18n.amount(amount)}
- OrderEvent.objects.bulk_create([OrderEvent.payment_captured_event(
- order=order, source=request.user, amount=amount, payment=payment)])
+ OrderEvent.payment_captured_event(
+ order=order, source=request.user,
+ amount=amount, payment=payment).save()
messages.success(request, msg)
return redirect('dashboard:order-details', order_pk=order.pk)
status = 400 if form.errors else 200
@@ -534,9 +535,8 @@ def mark_order_as_paid(request, order_pk):
if form.is_valid():
with transaction.atomic():
form.save()
- OrderEvent.objects.bulk_create([
- OrderEvent.manually_marked_as_paid_event(
- order=order, source=request.user)])
+ OrderEvent.manually_marked_as_paid_event(
+ order=order, source=request.user).save()
msg = pgettext_lazy(
'Dashboard message',
'Order manually marked as paid')
diff --git a/saleor/events/models/OrderEvent.py b/saleor/events/models/OrderEvent.py
index 283ee06805..483bd2357a 100644
--- a/saleor/events/models/OrderEvent.py
+++ b/saleor/events/models/OrderEvent.py
@@ -1,4 +1,4 @@
-from typing import List, Union, Dict
+from typing import Dict, List, Union
from django.conf import settings
from django.contrib.auth.base_user import AbstractBaseUser
@@ -7,7 +7,7 @@ from django.db import models
from django.utils.timezone import now
from prices import Money
-from saleor.account.models import Address
+from ...account.models import Address
from ...core.utils.json_serializer import CustomJsonEncoder
from ...order.models import Fulfillment, Order, OrderLine
from ...payment.models import Payment
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.py
index 4b7343262a..e527b77205 100644
--- a/saleor/graphql/order/mutations/orders.py
+++ b/saleor/graphql/order/mutations/orders.py
@@ -1,9 +1,9 @@
import graphene
from django.core.exceptions import ValidationError
-from ....events import models as event_models
from ....account.models import User
from ....core.utils.taxes import ZERO_TAXED_MONEY
+from ....events import models as event_models
from ....order import models
from ....order.utils import cancel_order
from ....payment import CustomPaymentChoices, PaymentError
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index e5e69e603c..9fba5262b5 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -5,7 +5,6 @@ from django.db import transaction
from django.shortcuts import get_object_or_404, redirect
from prices import Money, TaxedMoney
-from ..events.models import OrderEvent
from ..account.utils import store_user_address
from ..checkout import AddressType
from ..core.utils.taxes import (
@@ -13,6 +12,7 @@ from ..core.utils.taxes import (
from ..core.weight import zero_weight
from ..dashboard.order.utils import get_voucher_discount_for_order
from ..discount.models import NotApplicable
+from ..events.models import OrderEvent
from ..order import FulfillmentStatus, OrderStatus, emails
from ..order.models import Fulfillment, FulfillmentLine, Order, OrderLine
from ..payment import ChargeStatus
diff --git a/saleor/payment/utils.py b/saleor/payment/utils.py
index 024e8d598c..81f1e32c5f 100644
--- a/saleor/payment/utils.py
+++ b/saleor/payment/utils.py
@@ -9,10 +9,10 @@ from django.core.serializers.json import DjangoJSONEncoder
from django.db import transaction
from django.utils.translation import pgettext_lazy
-from ..events.models import OrderEvent
from ..account.models import Address, User
from ..checkout.models import Checkout
from ..core import analytics
+from ..events.models import OrderEvent
from ..events.types import OrderEvents, OrderEventsEmails
from ..order import utils as order_utils
from ..order.emails import send_payment_confirmation