Skip to content

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

Add deletion of granted refund to clearorders command (#16899)

Krzysztof Waliczek7da994d66f69
diff --git a/saleor/core/management/commands/clearorders.py b/saleor/core/management/commands/clearorders.py
index 6aeaa97558..fd4deb01a1 100644
--- a/saleor/core/management/commands/clearorders.py
+++ b/saleor/core/management/commands/clearorders.py
@@ -12,7 +12,15 @@ from ....checkout.models import Checkout, CheckoutLine, CheckoutMetadata
from ....discount.models import OrderDiscount, OrderLineDiscount
from ....giftcard.models import GiftCard, GiftCardEvent, GiftCardTag
from ....invoice.models import Invoice, InvoiceEvent
-from ....order.models import Fulfillment, FulfillmentLine, Order, OrderEvent, OrderLine
+from ....order.models import (
+ Fulfillment,
+ FulfillmentLine,
+ Order,
+ OrderEvent,
+ OrderGrantedRefund,
+ OrderGrantedRefundLine,
+ OrderLine,
+)
from ....payment.models import Payment, Transaction, TransactionEvent, TransactionItem
from ....warehouse.models import (
Allocation,
@@ -76,9 +84,15 @@ class Command(BaseCommand):
self.stdout.write("Removed checkouts")
def delete_payments(self):
+ order_granted_refund_lines = OrderGrantedRefundLine.objects.all()
+ order_granted_refund_lines._raw_delete(order_granted_refund_lines.db) # type: ignore[attr-defined] # raw access # noqa: E501
+
transaction_events = TransactionEvent.objects.all()
transaction_events._raw_delete(transaction_events.db) # type: ignore[attr-defined] # raw access # noqa: E501
+ order_granted_refunds = OrderGrantedRefund.objects.all()
+ order_granted_refunds._raw_delete(order_granted_refunds.db) # type: ignore[attr-defined] # raw access # noqa: E501
+
transaction_items = TransactionItem.objects.all()
transaction_items._raw_delete(transaction_items.db) # type: ignore[attr-defined] # raw access # noqa: E501