Skip to content

[18.0][MIG] hr_expense_invoice: Migration to version 18.0#308

Merged
OCA-git-bot merged 54 commits into
OCA:18.0from
Tecnativa:18.0-mig-hr_expense_payment
Sep 4, 2025
Merged

[18.0][MIG] hr_expense_invoice: Migration to version 18.0#308
OCA-git-bot merged 54 commits into
OCA:18.0from
Tecnativa:18.0-mig-hr_expense_payment

Conversation

@david-banon-tecnativa
Copy link
Copy Markdown
Contributor

@david-banon-tecnativa david-banon-tecnativa commented Jul 3, 2025

@Tecnativa @pedrobaeza @victoralmau
Superseedes #282 by @cav-adhoc while maintaining commit ownership.

I've made some minor adjustments, orignal PR looked good to me and only needed a rebase to work.

TT55529

@pedrobaeza
Copy link
Copy Markdown
Member

/ocabot migration hr_expense_invoice

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Jul 4, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Jul 4, 2025
10 tasks
Copy link
Copy Markdown
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check also the issue #302 if it's happening here as well, and you may want to fix it in all the versions.

expense_sheets_with_invoices = self.get_expense_sheets_with_invoices()
own_account_sheets = self.filtered(
lambda sheet: sheet.payment_mode == "own_account"
and not sheet.advance_sheet_id
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be put here, as it belongs to other module AFAIK.

@rafaelbn
Copy link
Copy Markdown
Member

rafaelbn commented Aug 4, 2025

Hello,

> Odoo Server Error
> RPC_ERROR
> 
> Odoo Server Error
> 
> Occured on oca-hr-expense-18-0-pr308-b683208461fa.runboat.odoo-community.org on model hr.expense.sheet on 2025-08-04 22:37:26 GMT
> 
> Traceback (most recent call last):
>   File "/opt/odoo/odoo/http.py", line 2123, in _transactioning
>     return service_model.retrying(func, env=self.env)
>   File "/opt/odoo/odoo/service/model.py", line 156, in retrying
>     result = func()
>   File "/opt/odoo/odoo/http.py", line 2090, in _serve_ir_http
>     response = self.dispatcher.dispatch(rule.endpoint, args)
>   File "/opt/odoo/odoo/http.py", line 2338, in dispatch
>     result = self.request.registry['ir.http']._dispatch(endpoint)
>   File "/opt/odoo/odoo/addons/base/models/ir_http.py", line 333, in _dispatch
>     result = endpoint(**request.params)
>   File "/opt/odoo/odoo/http.py", line 754, in route_wrapper
>     result = endpoint(self, *args, **params_ok)
>   File "/opt/odoo/addons/web/controllers/dataset.py", line 42, in call_button
>     action = call_kw(request.env[model], method, args, kwargs)
>   File "/opt/odoo/odoo/api.py", line 535, in call_kw
>     result = getattr(recs, name)(*args, **kwargs)
>   File "/opt/odoo/addons/hr_expense/models/hr_expense_sheet.py", line 595, in action_approve_expense_sheets
>     self._do_approve()
>   File "/mnt/data/odoo-addons-dir/hr_expense_invoice/models/hr_expense_sheet.py", line 185, in _do_approve
>     own_account_sheets = self.filtered(
>   File "/opt/odoo/odoo/models.py", line 6523, in filtered
>     return self.browse(rec.id for rec in self if func(rec))
>   File "/opt/odoo/odoo/models.py", line 6222, in browse
>     ids = tuple(ids)
>   File "/opt/odoo/odoo/models.py", line 6523, in <genexpr>
>     return self.browse(rec.id for rec in self if func(rec))
>   File "/mnt/data/odoo-addons-dir/hr_expense_invoice/models/hr_expense_sheet.py", line 187, in <lambda>
>     and not sheet.advance_sheet_id
> AttributeError: 'hr.expense.sheet' object has no attribute 'advance_sheet_id'
> 
> The above server error caused the following client error:
> RPC_ERROR: Odoo Server Error
>     RPCError@http://oca-hr-expense-18-0-pr308-b683208461fa.runboat.odoo-community.org/web/assets/3894c65/web.assets_web.min.js:3145:338
>     makeErrorFromResponse@http://oca-hr-expense-18-0-pr308-b683208461fa.runboat.odoo-community.org/web/assets/3894c65/web.assets_web.min.js:3148:163
>     rpc._rpc/promise</<@http://oca-hr-expense-18-0-pr308-b683208461fa.runboat.odoo-community.org/web/assets/3894c65/web.assets_web.min.js:3153:34
>     

Le me know please, when I can test again. Thank you!

Copy link
Copy Markdown
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and founded a but 🔴 . Please review it. thank you very much!

pedrobaeza and others added 21 commits August 5, 2025 12:51
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
@Gelojr
Copy link
Copy Markdown

Gelojr commented Aug 25, 2025 via email

@JordiBForgeFlow
Copy link
Copy Markdown
Member

JordiBForgeFlow commented Aug 25, 2025

@Gelojr I can reproduce the issue you mention when I create an expense report created with two expenses, where I only create a related invoice for one of them. Then I was able to post the expense report while keeping one of the vendor bill in draft.

This is not an issue with the migration of the module, as this bug exists also in prior versions. The problem is here: https://github.com/OCA/hr-expense/blob/17.0/hr_expense_invoice/models/hr_expense_sheet.py#L21 and https://github.com/OCA/hr-expense/pull/308/files#diff-406b9f2af65ef4b7b24c6638a958cf7301ddad72e846bc1c68083c281238282dR15

The method

def get_expense_sheets_with_invoices(self):
     return self.filtered(
         lambda sheet: all(expense.invoice_id for expense in sheet.expense_line_ids)
     )

Sould be using any not all

@david-banon-tecnativa do you agree? In any case we should handle this in a separate PR/Issue.

@Gelojr
Copy link
Copy Markdown

Gelojr commented Aug 25, 2025 via email

@pedrobaeza
Copy link
Copy Markdown
Member

Let's merge for now this one:

/ocabot merge nobump

@OCA-git-bot
Copy link
Copy Markdown
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 18.0-ocabot-merge-pr-308-by-pedrobaeza-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Aug 25, 2025
Signed-off-by pedrobaeza
@OCA-git-bot
Copy link
Copy Markdown
Contributor

@pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on this commit of 18.0-ocabot-merge-pr-308-by-pedrobaeza-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@pedrobaeza
Copy link
Copy Markdown
Member

pedrobaeza commented Aug 25, 2025

@david-banon-tecnativa please rebase and check the failing CI. You can at the same time add a commit with the fix for the other problem.

@rafaelbn
Copy link
Copy Markdown
Member

rafaelbn commented Aug 25, 2025

Hello @pedrobaeza ,

Is it a good idea merging this one with and existing bug?

This is not an issue with the migration of the module, as this bug exists also in prior versions

Fixing the bug is not a choice? Do you have an idea how do you want to FIX it?

Thank you!
Regards

PD @Gelojr @ArantxaSudon take care so in:

Known issues / Roadmap]

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

@pedrobaeza
Copy link
Copy Markdown
Member

Yes, the migration is correct as the problem is the same for all the versions, so you get at least the same module as in 17.0. Rest of the issues can be tackled in any moment. As now there's other problem, the fix may be included here, but you shouldn't block a migration because the discovering of a bug not related to the migration itself.

@david-banon-tecnativa david-banon-tecnativa force-pushed the 18.0-mig-hr_expense_payment branch from 5218e49 to 9acf553 Compare August 26, 2025 08:29
@david-banon-tecnativa
Copy link
Copy Markdown
Contributor Author

I’ve updated the tests and implemented a fix for expense sheets that include one sheet with an unposted invoice and another with no invoice, ensuring an error is raised as it shouldn't be postable until the invoice is confirmed.
I will backport to earlier versions once merged.

@pedrobaeza
Copy link
Copy Markdown
Member

@rafaelbn @Gelojr update your reviews.

Copy link
Copy Markdown

@Gelojr Gelojr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on the work @david-banon-tecnativa given the reported issue also exists in prior versions and will be handled separately, I’m approving this PR. The following tests were executed and all passed:

  • Test 1: Link an existing posted vendor bill to an expense and pay the report; transfer entries are created and the bill is reconciled -> OK.
  • Test 2: Try to link a Draft vendor bill to an expense line; action is blocked with the expected warning -> OK.
  • Test 3: Force an amount mismatch between the bill and the selected expenses; error is raised and posting/payment is blocked -> OK.
  • Test 4: Attempt to change the total on a vendor bill linked to expenses; system prevents the change and keeps the original total -> OK.
  • Test 5: Check smart buttons and counters to navigate between the expense report and the related vendor bill(s); links and counters work as expected -> OK.
  • Test 6: Create a vendor bill from an expense report and, while the bill remains in Draft, attempt to post the expense report; warning appears and posting is blocked -> OK.

Copy link
Copy Markdown
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/ocabot merge patch

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Sorry @rafaelbn you are not allowed to merge.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

@pedrobaeza
Copy link
Copy Markdown
Member

No need to bump version now for pip availability:

/ocabot merge nobump

@OCA-git-bot
Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 18.0-ocabot-merge-pr-308-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 85c091f into OCA:18.0 Sep 4, 2025
5 of 7 checks passed
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at e5f0a33. Thanks a lot for contributing to OCA. ❤️

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.