Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
add `FULFILLMENT_CREATED` webhook on `automatically_fulfill_digital_lines` action. (#13823)
Artur110a9388ac34
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dc543f20ce..f61766f24a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -43,6 +43,7 @@ All notable, unreleased changes to this project will be documented in this file.- Dry runs enabled: `AccountConfirmed`, `AccountConfirmationRequested`, `AccountChangeEmailRequested`- `AccountEmailChanged`, `AccountSetPasswordRequested`, `AccountDeleteRequested`, `GiftCardSent`,- `FulfillmentCreated`, `FulfillmentApproved`, `StaffSetPasswordRequested`+- Add missing `FULFILLMENT_CREATED` event call to `automatically_fulfill_digital_lines_with_fulfillment_created` action. - #13823, by @Air-t### Other changesdiff --git a/saleor/order/actions.py b/saleor/order/actions.pyindex 9a87c3f261..c88f86615b 100644--- a/saleor/order/actions.py+++ b/saleor/order/actions.py@@ -730,7 +730,7 @@ def automatically_fulfill_digital_lines(with traced_atomic_transaction():if not digital_lines_data:return- fulfillment, _ = Fulfillment.objects.get_or_create(order=order)+ fulfillment, created = Fulfillment.objects.get_or_create(order=order)fulfillments = []lines_info = []@@ -766,6 +766,8 @@ def automatically_fulfill_digital_lines(send_fulfillment_confirmation_to_customer(order, fulfillment, user=order.user, app=None, manager=manager)+ if created:+ manager.fulfillment_created(fulfillment)update_order_status(order)diff --git a/saleor/order/tests/test_order_actions.py b/saleor/order/tests/test_order_actions.pyindex 948e44b06e..7291316e36 100644--- a/saleor/order/tests/test_order_actions.py+++ b/saleor/order/tests/test_order_actions.py@@ -89,7 +89,9 @@ def order_with_digital_line(order, digital_content, stock, site_settings):@patch("saleor.order.actions.send_payment_confirmation", wraps=send_payment_confirmation)+@patch("saleor.plugins.manager.PluginsManager.fulfillment_created")def test_handle_fully_paid_order_digital_lines(+ mock_fulfillment_created,mock_send_payment_confirmation,send_fulfillment_confirmation_to_customer,order_with_digital_line,@@ -117,6 +119,7 @@ def test_handle_fully_paid_order_digital_lines(order.refresh_from_db()assert order.status == OrderStatus.FULFILLED+ mock_fulfillment_created.assert_called_once_with(fulfillment)@patch("saleor.order.actions.send_payment_confirmation")@@ -613,8 +616,13 @@ def test_fulfill_order_lines_without_inventory_tracking(order_with_lines):@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer")@patch("saleor.order.utils.get_default_digital_content_settings")+@patch("saleor.plugins.manager.PluginsManager.fulfillment_created")def test_fulfill_digital_lines(- mock_digital_settings, mock_email_fulfillment, order_with_lines, media_root+ mock_fulfillment_created,+ mock_digital_settings,+ mock_email_fulfillment,+ order_with_lines,+ media_root,):mock_digital_settings.return_value = {"automatic_fulfillment": True}line = order_with_lines.lines.all()[0]@@ -648,12 +656,18 @@ def test_fulfill_digital_lines(assert fulfillment_lines.count() == 1assert line.digital_content_urlassert mock_email_fulfillment.called+ mock_fulfillment_created.assert_called_once_with(fulfillment)@patch("saleor.order.actions.send_fulfillment_confirmation_to_customer")@patch("saleor.order.utils.get_default_digital_content_settings")+@patch("saleor.plugins.manager.PluginsManager.fulfillment_created")def test_fulfill_digital_lines_no_allocation(- mock_digital_settings, mock_email_fulfillment, order_with_lines, media_root+ mock_fulfillment_created,+ mock_digital_settings,+ mock_email_fulfillment,+ order_with_lines,+ media_root,):# givenmock_digital_settings.return_value = {"automatic_fulfillment": True}@@ -694,6 +708,7 @@ def test_fulfill_digital_lines_no_allocation(assert fulfillment_lines.count() == 1assert line.digital_content_urlassert mock_email_fulfillment.called+ mock_fulfillment_created.assert_called_once_with(fulfillment)@patch("saleor.plugins.manager.PluginsManager.order_updated")