Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Optimize order line deletion
Tomasz Szymanskic9b95b55f963
diff --git a/saleor/graphql/order/mutations/orders.py b/saleor/graphql/order/mutations/orders.pyindex fdc8d66eb0..330b0b63e4 100644--- a/saleor/graphql/order/mutations/orders.py+++ b/saleor/graphql/order/mutations/orders.py@@ -701,7 +701,7 @@ class OrderLineDelete(EditableOrderValidationMixin, BaseMutation):cls.validate_order(line.order)db_id = line.id- delete_order_line(line)+ delete_order_line(info.context.plugins, line)line.id = db_id# Create the removal eventdiff --git a/saleor/order/tests/test_order.py b/saleor/order/tests/test_order.pyindex 4727f22768..aba8a74650 100644--- a/saleor/order/tests/test_order.py+++ b/saleor/order/tests/test_order.py@@ -571,8 +571,10 @@ def test_order_weight_change_line_quantity(staff_user, order_with_lines):def test_order_weight_delete_line(order_with_lines):+ context_mock = Mock()+ context_mock.plugins.order_line_updated.return_value = Noneline = order_with_lines.lines.first()- delete_order_line(line)+ delete_order_line(context_mock, line)assert order_with_lines.weight == _calculate_order_weight_from_lines(order_with_lines)diff --git a/saleor/order/utils.py b/saleor/order/utils.pyindex cc554d0d93..10d72fbe4f 100644--- a/saleor/order/utils.py+++ b/saleor/order/utils.py@@ -317,7 +317,7 @@ def change_order_line_quantity(context, line, old_quantity, new_quantity):])else:- delete_order_line(line)+ delete_order_line(context.plugins, line)quantity_diff = old_quantity - new_quantity@@ -334,10 +334,9 @@ def change_order_line_quantity(context, line, old_quantity, new_quantity):)-def delete_order_line(line):+def delete_order_line(manager, line):"""Delete an order line from an order."""line.delete()- manager = get_plugins_manager()manager.order_line_deleted(line.order, line)diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.pyindex ef3c16e8a4..5f9fe29550 100644--- a/saleor/plugins/avatax/plugin.py+++ b/saleor/plugins/avatax/plugin.py@@ -449,7 +449,7 @@ class AvataxPlugin(BasePlugin):if self._skip_plugin(previous_value):return previous_value- return get_order_tax_data(order, self.config, True)+ get_order_tax_data(order, self.config, True)def order_line_updated(self, order: "Order", order_line: "OrderLine", previous_value: Any