Skip to content

[19.0][MIG] hr_expense_invoice: Migration to 19.0#357

Draft
dnplkndll wants to merge 66 commits into
OCA:19.0from
ledoent:19.0-mig-hr_expense_invoice
Draft

[19.0][MIG] hr_expense_invoice: Migration to 19.0#357
dnplkndll wants to merge 66 commits into
OCA:19.0from
ledoent:19.0-mig-hr_expense_invoice

Conversation

@dnplkndll
Copy link
Copy Markdown

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

Non-mechanical adaptations worth flagging

  • Hook target moved from `hr.expense.sheet.action_sheet_move_post` to `hr.expense.action_post()`. 19.0 core's `action_post` (`addons/hr_expense/models/hr_expense.py:1169`) auto-creates a receipt (own_account) or payment (company_account) per expense. Bill-linked expenses bypass that and route through the AP transfer-entry flow.
  • `account.move.expense_ids` renamed to `invoice_expense_ids` to avoid clash with 19.0 core's same-named One2many (which is the receipt-flow inverse on `account_move_id`, not the bill-link inverse on `invoice_id`). The picker domain on `hr.expense.invoice_id` now uses `invoice_expense_ids`.
  • `account.move.line.reconcile` cascade simplified. 18.0 traversed expense → sheet → set_to_paid. In 19.0, `hr.expense.state` is a computed mirror of `approval_state` + move/payment state; invalidating `amount_residual` after the AP-transfer line is reconciled is enough to recompute the cascade.
  • Sheet-only view block dropped (`hr_expense_sheet_form_view_inherit_sale_expense`) — `hr.expense.sheet` is gone. The `invoice_id` m2o on the expense form already exposes the "Create" context for new bills, replacing the per-line "Create Vendor Bill" button.
  • Bill-linked company_account path writes `approval_state='approved'` directly. Core's `_create_company_paid_moves` would otherwise duplicate the bill's obligation.

19.0 relevance

Two flows the module preserves that 19.0 core does not absorb:

  1. Pre-existing bill link — when a supplier sends an invoice to accounts (separately from the expense system), this module lets an employee file an expense that references the existing bill. Core's auto-receipt flow has no concept of "the bill already exists, just attach it."
  2. AP transfer entry for employee-paid bill-linked expenses — debit the bill's vendor AP, credit the employee's payable. Pays the employee through the existing bill-payment cycle instead of generating a parallel receipt.

UX with sheets removed: the expense form's `invoice_id` m2o is the entry point. Smart-button on `account.move` shows linked expense. Batch "create bill from N expenses" UX from the 18.0 sheet button is dropped — the 19.0 equivalent is selecting multiple expenses in the list and using core's per-expense `action_expense_create_invoice` (or a list-view action — out of scope for this slim MIG). Happy to add it if reviewers ask.

CI may surface tweaks needed on view xpaths (19.0's `hr.expense` form structure shifted around `product_id`/`quantity`); will iterate.

pedrobaeza and others added 30 commits May 27, 2026 10:59
Set supplier invoices on HR expenses
====================================

This module should be used when a supplier invoice is paid by an employee. It
allows to set  a supplier invoice for each expense line, adding the
corresponding journal items to transfer the debt to the employee.

Installation
============

Install the module the regular way.

Configuration
=============

You don't need to configure anything more to use this module.

Usage
=====

Instead of coding a full expense line, select an existing supplier invoice,
and then the rest of the fields will be auto-filled and grayed.

When you generate the expenses account entries, lines with invoices filled
will be generated as opposite of the payable move line of the invoice, and
both will be reconciled, letting the employee payable account as the only
open balance.

Known issues / Roadmap
======================

* Multiple payment terms for a supplier invoice are not handled correctly.
* Partial reconcile supplier invoices are also not correctly handled.

OCA Transbot updated translations from Transifex
…se view

OCA Transbot updated translations from Transifex
…l amount (OCA#237)

On the same expense, when we have 2 or more lines with different invoices, and each invoices have the same total amount, reconcile is not possible.

The fix is to exclude reconcile account.move.line, and the first time if we have more than one line to reconcile on the same amount, we keep the first.

OCA Transbot updated translations from Transifex
OCA Transbot updated translations from Transifex
[UPD] Update hr_expense_invoice.pot
Currently translated at 100.0% (4 of 4 strings)

Translation: hr-11.0/hr-11.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-11-0/hr-11-0-hr_expense_invoice/de/

Update translation files

Updated by Update PO files to match POT (msgmerge) hook in Weblate.
[UPD] Update hr_expense_invoice.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-12.0/hr-12.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/
Add expense info to invoice info or create/edit
From expense sheet, add action "Create Invoice" from multiple expenses
Change the way reference invoice_id is checked.
- No more onchange invoice_id that set values to expense
- Instead, check amount on expense and invoice during post entry
- Change the way to allow reconcile with > 2 account move lines
Currently translated at 100.0% (4 of 4 strings)

Translation: hr-12.0/hr-12.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/de/
Currently translated at 100.0% (4 of 4 strings)

Translation: hr-12.0/hr-12.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/es/

[UPD] README.rst

[UPD] Update hr_expense_invoice.pot

[UPD] README.rst

hr_expense_invoice 12.0.1.3.0

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-12.0/hr-12.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice/
hr_expense_invoice 12.0.1.3.1
[UPD] Update hr_expense_invoice.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
If not, the total amount of the expense won't match to invoices
with taxes.

[UPD] README.rst
… partners.

- Intercept properly the sheet paid action for not marking it as paid when
  reconciling the expense lines that belongs to invoices.
- Prevent set invoices paid when sheet paid by company.
- Some docstring.

Co-authored-by: Pedro M. Baeza <pedro.baeza@tecnativa.com>
Co-authored-by: Víctor Martínez <victor.martinez@tecnativa.com>

hr_expense_invoice 13.0.1.1.2

[UPD] Update hr_expense_invoice.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
…ing to sheet

hr_expense_invoice 13.0.1.2.0

[UPD] Update hr_expense_invoice.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
…ted with expense and improve domain to prevent set same invoice in different expenses.
…e is set)

hr_expense_invoice 13.0.1.3.0

[UPD] Update hr_expense_invoice.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: hr-expense-13.0/hr-expense-13.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice/
victoralmau and others added 21 commits May 27, 2026 10:59
Currently translated at 100.0% (15 of 15 strings)

Translation: hr-expense-16.0/hr-expense-16.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-16-0/hr-expense-16-0-hr_expense_invoice/it/
- The resulting entries after posting were not correct. Now, this is
  handled this way:

  * Paid by the company: no entry is created, as the invoice represents
    the AP balance. The expense sheet payment state is controlled
    through the linked invoices payment states.
  * Paid by employee: the vendor bill that core creates is voided, and
    instead, a journal entry transferring the AP balance to the employee
    is created against the original vendor balance, that is reconciled
    and given as paid.

- When an invoice is selected in the expense, the interface was not
  properly adapted, avoiding to change certain data, and the
  corresponding were not filled as well. Now both things are performed.
- Removed the non-sense register payment constraint.
- Added smart-button to navigate from invoice to expense, as there's
  no visible link in that direction.
- Avoid the need of the field `with_invoice_id`, as it was simply a
  question of putting properly the other field as invisible and without
  groups (apart from the already existing one with groups).
- Payment state and residual amount controlled correctly for these new
  cases.
- Tests cleanup, adapted (they were manipulated in some cases to match
  the weird previous result, like in payment states) and redundancies
  were removed.

TT49143
Currently translated at 100.0% (17 of 17 strings)

Translation: hr-expense-16.0/hr-expense-16.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-16-0/hr-expense-16-0-hr_expense_invoice/it/
Actions performed:
- Deprecated `hr.expense.reference` field as part of [1].
- Merged the `hr.expense.is_editable` and `hr.expense.sheet_is_editable`
  fields as part of [1].
- Renamed `hr.expense.unit_amount` to `hr.expense.price_unit`.
- Renamed `hr.expense.attachment_number` to `hr.expense.nb_attachment`.
- Renamed `hr.expense.approve_expense_sheets()` to
  `hr.expense.action_approve_expense_sheets()`.
- Renamed `hr.expense.account_move_id` to `hr.expense.account_move_ids`.
- Renamed `hr.expense.total_amount` to
  `hr.expense.total_amount_currency`.
- Inherit compute of `hr.expense.sheet.state` to consider expenses with
  linked invoices.
- Switched from old %-based string formatting to f-strings.
- Replaced the use of `attrs` in views with their equivalent Python
  expressions as part of [2].
- Adapted the `hr.expense.sheet` records creation in tests.
- Updated to use the employee partner from `hr.employee.work_contact_id`
  instead of `hr.employee.address_home_id` since it has been split into
  multiple fields.
- Added the `hr.expense.amount_residual` field to maintain the one
  invoice per expense functionality.
- Adapted test assertions for `hr.expense.sheet.state` since it is now
  a computed field.

Co-authored-by: desdelinux <luigys@vauxoo.com>

[1]: odoo/odoo#130244
[2]: odoo/odoo#104741
If an expense report includes invoices from different providers,
when posting move the report moves to "paid" and invoices are not
reconciled as paid, as it fails to reconcile the lines with the
transfer moves.

Use the correct partner, from current expense line from the report,
not always the same partner from first expense line.

Fixes OCA#273
…ot all

being postable when invoices are in draft
Odoo is handling the amount always tax included, so we need to transfer
to the invoice the proper base amount, not the price unit.
@OCA-git-bot OCA-git-bot added series:19.0 mod:hr_expense_invoice Module hr_expense_invoice labels May 27, 2026
@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_invoice branch 3 times, most recently from dd2ee47 to e3e4d05 Compare May 29, 2026 20:09
@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_invoice branch from e3e4d05 to e5c801b Compare May 30, 2026 14:57
@dnplkndll dnplkndll force-pushed the 19.0-mig-hr_expense_invoice branch from e5c801b to 218164f Compare May 30, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:hr_expense_invoice Module hr_expense_invoice series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.