Restock product inventory when an order is cancelled #9

Merged
Ghasemi merged 1 commit from fix/restock-on-cancel into master 2026-09-05 08:16:25 -04:00

1 commit

Author SHA1 Message Date
6431c28e0f Restock product inventory when an order is cancelled
checkout() decrements stock_quantity/increments sold_count per order
item, but cancellation never reversed it, so a cancelled order's stock
stayed permanently reduced. Add _restock_order_items(), called from
_transition() on the CANCELLED transition, using F() expressions to
reverse both counters atomically; wrap _transition() itself in
@transaction.atomic so the status change and restock can't partially
apply.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-05 15:08:02 +03:30