Skip to content

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

ORDER_CANCELED notification is fired at the end of transaction (#10242)

Michał Fijołekd9eecb2caa45
diff --git a/saleor/order/actions.py b/saleor/order/actions.py
index 96ee6e3308..327153d4ea 100644
--- a/saleor/order/actions.py
+++ b/saleor/order/actions.py
@@ -171,7 +171,9 @@ def cancel_order(
transaction.on_commit(lambda: manager.order_cancelled(order))
transaction.on_commit(lambda: manager.order_updated(order))
- send_order_canceled_confirmation(order, user, app, manager)
+ transaction.on_commit(
+ lambda: send_order_canceled_confirmation(order, user, app, manager)
+ )
def order_refunded(
diff --git a/saleor/order/tests/test_order_actions.py b/saleor/order/tests/test_order_actions.py
index 1abde05fc2..713035c3c6 100644
--- a/saleor/order/tests/test_order_actions.py
+++ b/saleor/order/tests/test_order_actions.py
@@ -10,6 +10,7 @@ from ...payment.models import Payment
from ...plugins.manager import get_plugins_manager
from ...product.models import DigitalContent
from ...product.tests.utils import create_image
+from ...tests.utils import flush_post_commit_hooks
from ...warehouse.models import Allocation, Stock
from .. import FulfillmentStatus, OrderEvents, OrderStatus
from ..actions import (
@@ -236,6 +237,7 @@ def test_cancel_order(
order_line__order=order, quantity_allocated__gt=0
).exists()
+ flush_post_commit_hooks()
send_order_canceled_confirmation_mock.assert_called_once_with(
order, None, None, manager
)