Skip to content

[16.0][FIX] Add ondelete=cascade to wizard item wiz_id fields#688

Open
dnplkndll wants to merge 1 commit into
ForgeFlow:16.0from
kencove:16.0-fix-rma-refund-autovacuum
Open

[16.0][FIX] Add ondelete=cascade to wizard item wiz_id fields#688
dnplkndll wants to merge 1 commit into
ForgeFlow:16.0from
kencove:16.0-fix-rma-refund-autovacuum

Conversation

@dnplkndll
Copy link
Copy Markdown

Summary

Fix ForeignKeyViolation errors when ir.autovacuum cleans up transient wizard records.

Without ondelete="cascade" on the wiz_id field, deleting the parent wizard leaves orphan child items that still reference it, causing FK constraint violations:

ForeignKeyViolation: UPDATE or DELETE on table "rma_refund" violates foreign key constraint
"rma_refund_item_wiz_id_fkey" on table "rma_refund_item"
DETAIL: Key (id)=(123) is still referenced from table "rma_refund_item".

This follows the pattern from PR #489 (commit 03ecdff) which fixed the same issue for rma_make_picking_wizard_item.

Affected wizards

Module TransientModel
rma_account rma.refund.item
rma_purchase rma.order.line.make.purchase.order.item
rma_sale rma.order.line.make.sale.order.item
rma_put_away rma_make_put_away_item.wizard
rma_scrap rma_make_scrap_item.wizard

Test plan

  • Pre-commit hooks pass
  • Wait for ir.autovacuum cron to run and verify no FK errors in logs

Fix ForeignKeyViolation errors when ir.autovacuum cleans up transient
wizard records. Without ondelete="cascade" on wiz_id, deleting the
parent wizard leaves orphan child items that still reference it,
causing FK constraint violations.

This follows the pattern from commit 03ecdff which fixed the same
issue for rma_make_picking_wizard_item.

Affected wizards:
- rma.refund.item (rma_account)
- rma.order.line.make.purchase.order.item (rma_purchase)
- rma.order.line.make.sale.order.item (rma_sale)
- rma_make_put_away_item.wizard (rma_put_away)
- rma_make_scrap_item.wizard (rma_scrap)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@dnplkndll
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant