Skip to content

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

Simplify logic by using exclude

Unknown45548092259b
diff --git a/saleor/order/utils.py b/saleor/order/utils.py
index 9026215586..9d3a690247 100644
--- a/saleor/order/utils.py
+++ b/saleor/order/utils.py
@@ -122,13 +122,8 @@ def cancel_order(order, restock):
order.status = OrderStatus.CANCELED
order.save(update_fields=['status'])
- payments = order.payments.filter(
- is_active=True,
- charge_status__in=[
- ChargeStatus.NOT_CHARGED,
- ChargeStatus.PARTIALLY_CHARGED,
- ChargeStatus.FULLY_CHARGED,
- ChargeStatus.PARTIALLY_REFUNDED])
+ payments = order.payments.filter(is_active=True).exclude(
+ charge_status=ChargeStatus.FULLY_REFUNDED)
for payment in payments:
if payment.can_refund():