Skip to content

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

[Bugfix] Fix trigger the FULFILLMENT_APPPROVED webhook for partial fulfillments (#11824)

Damian Wysockib3f44427b8bc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1ae653c95..2482e0c47d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -48,6 +48,7 @@ Just so you know, changes mentioned in this section are in a preview state and c
- Add new `PRODUCT_VARIANT_STOCK_UPDATED` event - #11665 by @jakubkuc
- Disable websocket support by default in `uvicorn` worker configuration - #11785 by @NyanKiyoshi
- Fix send user email change notification - #11840 by @jakubkuc
+- Fix trigger the `FULFILLMENT_APPPROVED` webhook for partial fulfillments - #11824 by @d-wysocki
# 3.10.0 [Unreleased]
diff --git a/saleor/graphql/order/tests/mutations/test_fulfillment.py b/saleor/graphql/order/tests/mutations/test_fulfillment.py
index e47da89d47..5f026f4772 100644
--- a/saleor/graphql/order/tests/mutations/test_fulfillment.py
+++ b/saleor/graphql/order/tests/mutations/test_fulfillment.py
@@ -2085,9 +2085,11 @@ def test_fulfillment_approve_when_stock_is_exceeded_and_flag_disabled(
assert expected_error in errors
+@patch("saleor.plugins.manager.PluginsManager.fulfillment_approved")
@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer", autospec=True)
def test_fulfillment_approve_partial_order_fulfill(
mock_email_fulfillment,
+ mock_fulfillment_approved,
staff_api_client,
fulfillment_awaiting_approval,
permission_manage_orders,
@@ -2133,6 +2135,7 @@ def test_fulfillment_approve_partial_order_fulfill(
assert fulfillment_awaiting_approval.status == FulfillmentStatus.FULFILLED
assert mock_email_fulfillment.call_count == 0
+ mock_fulfillment_approved.assert_called_once_with(fulfillment_awaiting_approval)
def test_fulfillment_approve_invalid_status(
diff --git a/saleor/order/actions.py b/saleor/order/actions.py
index dd5db3722d..7b2012eab0 100644
--- a/saleor/order/actions.py
+++ b/saleor/order/actions.py
@@ -482,9 +482,9 @@ def approve_fulfillment(
update_order_status(order)
call_event(manager.order_updated, order)
+ call_event(manager.fulfillment_approved, fulfillment)
if order.status == OrderStatus.FULFILLED:
call_event(manager.order_fulfilled, order)
- transaction.on_commit(lambda f=fulfillment: manager.fulfillment_approved(f))
if gift_card_lines_info:
gift_cards_create(