Restock product inventory when an order is cancelled #9
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "fix/restock-on-cancel"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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