Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix race condition on send_fulfillment-confirmation
fowczrek4e1d40417062
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f6b6d7c656..3b750896ef 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ All notable, unreleased changes to this project will be documented in this file.- Drop `data` field from checkout line model - #6961 by @fowczarek- Fix `totalCount` on connection resolver without `first` or `last` - #6975 by @fowczarek- Fix variant resolver on `DigitalContent` - #6983 by @fowczarek+- Fix race condition on `send_fulfillment-confirmation` - #6988 by @fowczarek### Breaking- Multichannel MVP: Multicurrency - #6242 by @fowczarek @d-wysockidiff --git a/saleor/order/actions.py b/saleor/order/actions.pyindex 2c0f5851d3..9530bdaabd 100644--- a/saleor/order/actions.py+++ b/saleor/order/actions.py@@ -175,6 +175,7 @@ def order_returned(manager.order_updated(order)def order_fulfilled(fulfillments: List["Fulfillment"],user: "User",@@ -506,11 +507,13 @@ def create_fulfillments()FulfillmentLine.objects.bulk_create(fulfillment_lines)- order_fulfilled(- fulfillments,- requester,- fulfillment_lines,- notify_customer,+ transaction.on_commit(+ lambda: order_fulfilled(+ fulfillments,+ requester,+ fulfillment_lines,+ notify_customer,+ ))return fulfillmentsdiff --git a/saleor/order/tests/test_fulfullments_actions.py b/saleor/order/tests/test_fulfullments_actions.pyindex de792a0a22..1fcbdf1587 100644--- a/saleor/order/tests/test_fulfullments_actions.py+++ b/saleor/order/tests/test_fulfullments_actions.py@@ -3,6 +3,7 @@ from unittest.mock import patchimport pytestfrom ...core.exceptions import InsufficientStock+from ...tests.utils import flush_post_commit_hooksfrom ...warehouse.models import Allocation, Stockfrom ..actions import create_fulfillmentsfrom ..models import FulfillmentLine, OrderStatus@@ -27,6 +28,7 @@ def test_create_fulfillments([fulfillment] = create_fulfillments(staff_user, order, fulfillment_lines_for_warehouses, True)+ flush_post_commit_hooks()order.refresh_from_db()fulfillment_lines = FulfillmentLine.objects.filter(@@ -75,6 +77,7 @@ def test_create_fulfillments_without_notification([fulfillment] = create_fulfillments(staff_user, order, fulfillment_lines_for_warehouses, False)+ flush_post_commit_hooks()order.refresh_from_db()fulfillment_lines = FulfillmentLine.objects.filter(@@ -132,6 +135,7 @@ def test_create_fulfillments_many_warehouses([fulfillment1, fulfillment2] = create_fulfillments(staff_user, order, fulfillment_lines_for_warehouses, False)+ flush_post_commit_hooks()order.refresh_from_db()fulfillment_lines = FulfillmentLine.objects.filter(@@ -179,6 +183,7 @@ def test_create_fulfillments_with_one_line_empty_quantity([fulfillment] = create_fulfillments(staff_user, order, fulfillment_lines_for_warehouses, True)+ flush_post_commit_hooks()order.refresh_from_db()fulfillment_lines = FulfillmentLine.objects.filter(@@ -224,6 +229,7 @@ def test_create_fulfillments_with_variant_without_inventory_tracking([fulfillment] = create_fulfillments(staff_user, order, fulfillment_lines_for_warehouses, True)+ flush_post_commit_hooks()order.refresh_from_db()fulfillment_lines = FulfillmentLine.objects.filter(@@ -266,6 +272,7 @@ def test_create_fulfillments_without_allocations([fulfillment] = create_fulfillments(staff_user, order, fulfillment_lines_for_warehouses, True)+ flush_post_commit_hooks()order.refresh_from_db()fulfillment_lines = FulfillmentLine.objects.filter(