Skip to content

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

Make sure to always set a correct default value for discount propagation flag (#17658)

Maciej Korycinskif6a3751a8bc2
diff --git a/saleor/graphql/channel/mutations/channel_create.py b/saleor/graphql/channel/mutations/channel_create.py
index 423d069b26..425429e933 100644
--- a/saleor/graphql/channel/mutations/channel_create.py
+++ b/saleor/graphql/channel/mutations/channel_create.py
@@ -294,8 +294,11 @@ class ChannelCreate(DeprecatedModelMutation):
cleaned_input["slug"] = slugify(slug)
if stock_settings := cleaned_input.get("stock_settings"):
cleaned_input["allocation_strategy"] = stock_settings["allocation_strategy"]
- if order_settings := cleaned_input.get("order_settings"):
- clean_input_order_settings(order_settings, cleaned_input, instance)
+
+ order_settings = cleaned_input.get("order_settings") or {
+ "use_legacy_line_discount_propagation_for_order": False
+ }
+ clean_input_order_settings(order_settings, cleaned_input, instance)
if checkout_settings := cleaned_input.get("checkout_settings"):
clean_input_checkout_settings(checkout_settings, cleaned_input)
diff --git a/saleor/graphql/channel/tests/mutations/test_channel_create.py b/saleor/graphql/channel/tests/mutations/test_channel_create.py
index 61e21ab68a..9485fc77cf 100644
--- a/saleor/graphql/channel/tests/mutations/test_channel_create.py
+++ b/saleor/graphql/channel/tests/mutations/test_channel_create.py
@@ -899,7 +899,12 @@ def test_channel_create_set_allow_unpaid_orders(
@pytest.mark.parametrize(
("use_legacy_input", "expected_result"),
- [(True, True), (False, False), (None, False)],
+ [
+ ({"useLegacyLineDiscountPropagation": True}, True),
+ ({"useLegacyLineDiscountPropagation": False}, False),
+ (None, False),
+ ({"allowUnpaidOrders": False}, False),
+ ],
)
def test_channel_create_set_use_legacy_line_discount_propagation(
use_legacy_input,
@@ -918,7 +923,7 @@ def test_channel_create_set_use_legacy_line_discount_propagation(
"slug": slug,
"currencyCode": currency_code,
"defaultCountry": default_country,
- "orderSettings": {"useLegacyLineDiscountPropagation": use_legacy_input},
+ "orderSettings": use_legacy_input,
}
}
diff --git a/saleor/graphql/channel/tests/mutations/test_channel_update.py b/saleor/graphql/channel/tests/mutations/test_channel_update.py
index c1f69ae704..e737fe79f3 100644
--- a/saleor/graphql/channel/tests/mutations/test_channel_update.py
+++ b/saleor/graphql/channel/tests/mutations/test_channel_update.py
@@ -1635,12 +1635,14 @@ def test_channel_update_default_transaction_flow_strategy_with_payment_permissio
@pytest.mark.parametrize(
("use_legacy_input", "expected_result", "current_value_on_db"),
[
- (True, True, True),
- (True, True, False),
- (False, False, True),
- (False, False, False),
+ ({"useLegacyLineDiscountPropagation": True}, True, True),
+ ({"useLegacyLineDiscountPropagation": True}, True, False),
+ ({"useLegacyLineDiscountPropagation": False}, False, True),
+ ({"useLegacyLineDiscountPropagation": False}, False, False),
(None, True, True),
(None, False, False),
+ ({"allowUnpaidOrders": False}, False, False),
+ ({"allowUnpaidOrders": True}, True, True),
],
)
def test_channel_update_set_use_legacy_line_discount_propagation(
@@ -1659,7 +1661,7 @@ def test_channel_update_set_use_legacy_line_discount_propagation(
variables = {
"id": channel_id,
"input": {
- "orderSettings": {"useLegacyLineDiscountPropagation": use_legacy_input},
+ "orderSettings": use_legacy_input,
},
}