Skip to content

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

Draft
dnplkndll wants to merge 32 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 32 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.

ernestotejeda and others added 30 commits May 27, 2026 10:03
This module lets to cancel and correct expenses. It adds a cancel
button on the expense sheet that undo reconciliations and delete
payments and journal entries.
The multi own account test has been removed as it is no longer possible
in odoo core to register the payment of several expense sheet reports at
the same time.

Co-Authored By:
Stefan Ungureanu
aiendry-aktivsoftware
In this version, if a product doesn't have cost, you are only able
to enter total amount, so the test should be adjusted to this
condition.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-expense-17.0/hr-expense-17.0-hr_expense_cancel
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-17-0/hr-expense-17-0-hr_expense_cancel/
Currently translated at 100.0% (4 of 4 strings)

Translation: hr-expense-17.0/hr-expense-17.0-hr_expense_cancel
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-17-0/hr-expense-17-0-hr_expense_cancel/it/
@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_cancel branch from 10bc2ca to a91b5f6 Compare May 27, 2026 14:40
dnplkndll added 2 commits May 27, 2026 10:46
Odoo 19.0 removed hr.expense.sheet. Core's hr.expense.action_reset()
(addons/hr_expense/models/hr_expense.py:1210) already reverses + cancels
posted moves and unlinks draft moves. This module augments that flow
with the payment-side teardown that core leaves intact:

- Override hr.expense.action_reset() to draft-cancel linked payments
  (via hr_expense_payment.payment_ids) and unreconcile their lines
  before calling super().
- _remove_reconcile_hr_invoice + _remove_move_reconcile helpers move
  from sheet to expense, work per-expense rather than per-sheet.
- Drop views/hr_expense_views.xml — core already exposes the Reset
  button on the expense form; we just augment the behaviour.
- Tests rewritten against the 19.0 per-expense flow (action_submit
  / action_approve / post_expenses_with_wizard / action_pay).

account_payment.action_draft_cancel() helper unchanged — action_draft()
and action_cancel() still exist on account.payment in 19.0.
@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_cancel branch 3 times, most recently from 1b60db9 to 5472351 Compare May 29, 2026 20:09
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.