Skip to content

[19.0][MIG] hr_expense_cancel: Migration to 19.0#356

Draft
dnplkndll wants to merge 26 commits into
OCA:19.0from
ledoent:19.0-mig-hr_expense_cancel
Draft

[19.0][MIG] hr_expense_cancel: Migration to 19.0#356
dnplkndll wants to merge 26 commits into
OCA:19.0from
ledoent:19.0-mig-hr_expense_cancel

Conversation

@dnplkndll

Copy link
Copy Markdown

Port of `hr_expense_cancel` from 18.0 to 19.0 (migration guide).

Depends on OCA/hr-expense#355 (hr_expense_payment) — pinned via `test-requirements.txt`.

Non-mechanical adaptations worth flagging

  • Hook target changed from `hr.expense.sheet.action_cancel` to `hr.expense.action_reset()`. 19.0 core's `action_reset` (`addons/hr_expense/models/hr_expense.py:1210`) already reverses + cancels posted moves and unlinks draft moves. This module just augments it with payment-side teardown.
  • Dropped `views/hr_expense_views.xml` — core already exposes the Reset button on the expense form via `action_reset`. The 18.0 module added a custom "Cancel all related operations" button on the sheet; that's redundant in 19.0 because the augmented `action_reset` is invoked by the existing core button.
  • Per-expense, not per-sheet: helpers `_remove_reconcile_hr_invoice` and `_remove_move_reconcile` work on `expense.account_move_id` (single move per expense in 19.0) rather than the sheet's m2m `account_move_ids`.
  • `payment.state` rename: 18.0 used `'cancel'`; 19.0 core uses `'canceled'`. Filter expression updated.
  • `account.payment.action_draft_cancel()` helper unchanged — `action_draft()` and `action_cancel()` still exist on `account.payment` in 19.0 (verified at `/addons/account/models/account_payment.py:1152, 1161`).

19.0 relevance

The 18.0 module's value (let the user undo a posted expense + its payment + reconciliation chain) is partly absorbed by core's `action_reset` but the payment + cross-module reconcile cleanup is left to the addon ecosystem. `hr_expense_invoice` (Wave D, not yet ported) also needs the cross-module unreconcile path to keep working when reset happens after a bill has been generated.

Tests

Test What it gates
`test_action_reset_unposted` Reset on a posted-but-unpaid employee expense reverses the move and returns state to draft.
`test_action_reset_paid_own_account` Reset on a paid employee expense draft-cancels the payment + unreconciles before reversing.
`test_action_reset_company_account` Reset on a company-paid expense reverses the auto-generated move.
`test_action_reset_blocked_on_hashed_journal` Reset must fail (UserError) when the linked move sits on a hash-locked journal.

The `Detect unreleased dependencies` CI red is expected — `[DO NOT MERGE]` dep-pin to #355. Strip the pin once #355 lands.

@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_cancel branch 4 times, most recently from 1b60db9 to 5472351 Compare May 29, 2026 20:09
@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_cancel branch 4 times, most recently from d6ad906 to 62ef7a7 Compare June 19, 2026 19:12
mav-adhoc and others added 6 commits June 22, 2026 14:28
hr.expense.sheet was removed in 19.0; the reset flow moves to a
per-expense hr.expense.action_reset() override.

- action_reset() tears down linked payments (unreconcile + draft-cancel)
  and the posted move before super(), so core's reset guard passes.
@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_cancel branch from 62ef7a7 to fa7af75 Compare June 22, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:hr_expense_cancel Module hr_expense_cancel series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.