Skip to content

[18.0][FIX] hr_expense_invoice: Allow mixed expense reports (with and without invoices)#331

Open
dtec-landoo wants to merge 1 commit intoOCA:18.0from
dtec-landoo:18.0-mixed-expense-reports
Open

[18.0][FIX] hr_expense_invoice: Allow mixed expense reports (with and without invoices)#331
dtec-landoo wants to merge 1 commit intoOCA:18.0from
dtec-landoo:18.0-mixed-expense-reports

Conversation

@dtec-landoo
Copy link

Description of the issue/feature:

Fixes an issue where expense reports containing a mix of expenses with an associated vendor bill and expenses without a vendor bill could not be processed, raising an "Invalid Operation" error.

Currently, the hr_expense_invoice module assumes that either all or none of the expenses in a report have an associated invoice. When a mixed report is submitted, the _check_can_create_move constraint and the _do_create_moves method fail to handle the non-invoiced lines properly, crashing the approval/posting process.

This PR fixes the issue by:

Modifying _do_create_moves to temporarily remove invoiced expenses from the sheet before calling super(). This allows Odoo's standard process to generate the regular journal entries for non-invoiced expenses. Afterwards, the invoiced expenses are restored to the sheet and their specific AP transfer moves are generated.

Changing any to all in the _check_can_create_move validations so mixed sheets are not incorrectly blocked.

Modifying action_sheet_move_post to properly filter sheets passing to super().

Bonus fix: Adds support for in_refund moves (vendor refunds) in _check_expense_ids so negative expenses don't raise a validation error when comparing amount_total.

Steps to reproduce:

Install hr_expense_invoice.

Create an Expense without a vendor bill (e.g., "Expense 1", Paid by Company).

Create an Expense with an associated vendor bill (e.g., "Expense 2", Paid by Company).

Select both expenses and create a single Expense Report.

Submit the report and click on "Approve" / "Post Journal Entries".

Current behavior:

An "Invalid Operation" (or validation) error is raised because the system tries to process the mixed lines uniformly, failing to generate the standard accounting entries for the non-invoiced expenses. This forces the user to split the expenses into separate reports.

Expected behavior:

The mixed expense report is successfully approved and posted. Non-invoiced expenses generate their standard journal entries, and invoiced expenses are processed correctly alongside them within the same report.

Fixes #330

@dtec-landoo dtec-landoo force-pushed the 18.0-mixed-expense-reports branch 15 times, most recently from d47a79c to 9b7ad07 Compare March 11, 2026 09:44
@dtec-landoo dtec-landoo force-pushed the 18.0-mixed-expense-reports branch from 9b7ad07 to ac6157d Compare March 11, 2026 09:45
@dtec-landoo
Copy link
Author

@pedrobaeza @victoralmau

Hi!

I've just updated the PR. All the CI checks, tests, and Codecov coverage are now completely green.

It is ready for review whenever you have a moment. Let me know if you need any further changes. Thanks!

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.

[FIX][18.0] hr_expense_invoice: Allow mixed expense reports (with and without invoices)

1 participant