Skip to content

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

Fix double avatax requests for created order (#11509)

Maciej Korycinski9e45fc88aacc
diff --git a/saleor/order/actions.py b/saleor/order/actions.py
index e19192c3d6..a6a26f96e1 100644
--- a/saleor/order/actions.py
+++ b/saleor/order/actions.py
@@ -112,7 +112,7 @@ def order_created(
manager=manager,
)
site_settings = Site.objects.get_current().settings
- if site_settings.automatically_confirm_all_new_orders:
+ if site_settings.automatically_confirm_all_new_orders or from_draft:
order_confirmed(order, user, app, manager)
diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.py
index 9abdc07eae..eacc21b93c 100644
--- a/saleor/plugins/avatax/plugin.py
+++ b/saleor/plugins/avatax/plugin.py
@@ -352,8 +352,8 @@ class AvataxPlugin(BasePlugin):
raise TaxError(customer_msg)
return previous_value
- def order_created(self, order: "Order", previous_value: Any) -> Any:
- if not self.active or order.is_unconfirmed():
+ def order_confirmed(self, order: "Order", previous_value: Any) -> Any:
+ if not self.active:
return previous_value
request_data = get_order_request_data(order, self.config)
if not request_data:
@@ -367,9 +367,6 @@ class AvataxPlugin(BasePlugin):
)
return previous_value
- def order_confirmed(self, order: "Order", previous_value: Any) -> Any:
- return self.order_created(order, previous_value)
-
def calculate_checkout_line_total(
self,
checkout_info: "CheckoutInfo",
diff --git a/saleor/plugins/avatax/tests/test_avatax.py b/saleor/plugins/avatax/tests/test_avatax.py
index cf9d51d278..296b603081 100644
--- a/saleor/plugins/avatax/tests/test_avatax.py
+++ b/saleor/plugins/avatax/tests/test_avatax.py
@@ -3546,7 +3546,7 @@ def test_show_taxes_on_storefront(plugin_configuration):
@patch("saleor.plugins.avatax.plugin.api_post_request_task.delay")
@override_settings(PLUGINS=["saleor.plugins.avatax.plugin.AvataxPlugin"])
-def test_order_created(
+def test_order_confirmed(
api_post_request_task_mock, order, order_line, plugin_configuration
):
# given
@@ -3562,7 +3562,7 @@ def test_order_created(
manager = get_plugins_manager()
# when
- manager.order_created(order)
+ manager.order_confirmed(order)
# then
address = order.billing_address