Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] hr_expense_invoice: Migration to 18.0 #282

Open
wants to merge 60 commits into
base: 18.0
Choose a base branch
from

Conversation

cav-adhoc
Copy link

@cav-adhoc cav-adhoc commented Dec 12, 2024

Key changes:

  • Refactored to accommodate Odoo 18.0 new behavior where accounting entries are created automatically upon expense approval (rather than in a separate step as in previous versions). With this module still works like v17
  • Renamed action_sheet_move_create to action_sheet_move_post to align with new Odoo code
  • Inherit _do_approve method to properly handle expenses with invoices during approval
  • Added comprehensive validation to ensure proper expense handling with linked invoices
  • Updated test cases with action_sheet_move_post

@cav-adhoc cav-adhoc mentioned this pull request Dec 12, 2024
8 tasks
@cav-adhoc cav-adhoc force-pushed the 18.0-mig-hr_expense_invoice branch 7 times, most recently from cc93616 to a75fcb3 Compare December 16, 2024 17:13
@cav-adhoc
Copy link
Author

/ocabot migration hr_expense_invoice

@OCA-git-bot
Copy link
Contributor

Sorry @cav-adhoc you are not allowed to mark the addon tobe migrated.

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.

@cav-adhoc
Copy link
Author

cav-adhoc commented Dec 23, 2024

@melanievvl @xmglord @luisg123v @pedrobaeza Hello! Can you guys review this? Thanks in advance!

@cav-adhoc
Copy link
Author

Hi @melanievvl, @xmglord, @luisg123v! Sorry to ask again, but could you please review the migration code? Thank you!

@Saran440
Copy link
Member

/ocabot migration hr_expense_invoice

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Jan 17, 2025
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@rov-adhoc
Copy link

@pedrobaeza Hi! Would you be able to help us with the merge of this PR? Thanks in advance! Regards

@pedrobaeza
Copy link
Member

Expense paid by he employee's own account -> As it should be reimbursed to them, it creates a vendor bill.

I don't think so. The vendor bill is already provided, so you should create an extra journal entry cancelling that debt and assigning it to the employee, as it was in previous versions.

@cav-adhoc
Copy link
Author

@pedrobaeza Hi! That is a change in the Odoo code (here is the commit where this functionality change was added: (https://github.com/odoo-dev/odoo/blob/17e7e853eaf0c2b726007e0b4eee1a8a190e3613/addons/hr_expense/models/hr_expense_sheet.py#L698)).

If we override that behavior, it would differ from Odoo's approach

@pedrobaeza
Copy link
Member

This module is for changing that behavior indeed, and make it comfortable to match existing vendor bills. If not, the module is not doing anything. Please check how it's done in previous versions.

@gjlong68
Copy link

gjlong68 commented Apr 9, 2025

error
image

pedrobaeza and others added 5 commits April 10, 2025 12:39
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
LoisRForgeFlow and others added 23 commits April 10, 2025 12:39
Hide quantity label and UoM field when selecting an invoice, as
it is done with quantity field.

hr_expense_invoice 15.0.1.1.0
… to use amount_total from invoices.

If residual amount from invoice is not the same, it should not show an error.

TT40175

hr_expense_invoice 15.0.1.1.1
Translated using Weblate (Italian)

Currently translated at 100.0% (15 of 15 strings)

Translation: hr-expense-15.0/hr-expense-15.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-15-0/hr-expense-15-0-hr_expense_invoice/it/

[UPD] README.rst

Update translation files

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

Translation: hr-expense-15.0/hr-expense-15.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-15-0/hr-expense-15-0-hr_expense_invoice/
Currently translated at 100.0% (15 of 15 strings)

Translation: hr-expense-15.0/hr-expense-15.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-15-0/hr-expense-15-0-hr_expense_invoice/it/
Currently translated at 100.0% (15 of 15 strings)

Translation: hr-expense-15.0/hr-expense-15.0-hr_expense_invoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-15-0/hr-expense-15-0-hr_expense_invoice/es/
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
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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/
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
@cav-adhoc cav-adhoc force-pushed the 18.0-mig-hr_expense_invoice branch 5 times, most recently from 7beac2c to 1d99272 Compare April 11, 2025 20:00
@cav-adhoc cav-adhoc force-pushed the 18.0-mig-hr_expense_invoice branch from 1d99272 to 7d90c0f Compare April 11, 2025 20:09
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.