Skip to content

[16.0][MIG] sale_expense_manual_reinvoice: Migration to 16.0#296

Open
MarwanBHL wants to merge 15 commits intoOCA:16.0from
MarwanBHL:16.0-mig-sale_expense_manual_reinvoice
Open

[16.0][MIG] sale_expense_manual_reinvoice: Migration to 16.0#296
MarwanBHL wants to merge 15 commits intoOCA:16.0from
MarwanBHL:16.0-mig-sale_expense_manual_reinvoice

Conversation

@MarwanBHL
Copy link

Migration to 16.0

@MarwanBHL MarwanBHL force-pushed the 16.0-mig-sale_expense_manual_reinvoice branch from 9eb578f to 122eebb Compare March 25, 2025 22:20
@MarwanBHL MarwanBHL mentioned this pull request Mar 26, 2025
9 tasks
@yboujraf
Copy link

Anybody to validate the PR ?

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Aug 17, 2025
ivantodorovich and others added 15 commits August 19, 2025 07:52
Currently translated at 100.0% (24 of 24 strings)

Translation: hr-expense-15.0/hr-expense-15.0-sale_expense_manual_reinvoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-15-0/hr-expense-15-0-sale_expense_manual_reinvoice/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

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

Translation: hr-expense-15.0/hr-expense-15.0-sale_expense_manual_reinvoice
Translate-URL: https://translation.odoo-community.org/projects/hr-expense-15-0/hr-expense-15-0-sale_expense_manual_reinvoice/it/
@MarwanBHL MarwanBHL force-pushed the 16.0-mig-sale_expense_manual_reinvoice branch from 122eebb to 1857650 Compare August 19, 2025 05:53
@MarwanBHL
Copy link
Author

Hello @ivantodorovich can you check this migration PR please.

Thank you

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Aug 24, 2025
@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Dec 28, 2025
@MarwanBHL
Copy link
Author

@pedrobaeza @Saran440 Hello, sorry for the ping, but I haven't received any response in 9 months. Could you please check this PR? Thank you 😃

@pedrobaeza
Copy link
Member

/ocabot migration sale_expense_manual_reinvoice

You can review other PRs, and ask in exchange that they review yours.

@OCA-git-bot OCA-git-bot added this to the 16.0 milestone Dec 29, 2025
@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jan 4, 2026
Copy link

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

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

Automated Review -- Tests Failed

1. Root Cause

The test failure is caused by a database connection error during the Odoo startup process, which prevents the test environment from initializing properly. This is not a code logic issue in the module itself but rather an infrastructure or configuration problem in the test environment (likely related to Runboat setup).


2. Suggested Fix

There is no code fix required for the test failure itself, as it's a setup issue. However, to make the module more robust, consider adding a check for expense_id in _sale_can_be_reinvoice to prevent potential errors if self.expense_id is not set:

# In sale_expense_manual_reinvoice/models/account_move_line.py, line ~12
def _sale_can_be_reinvoice(self):
    # OVERRIDE to skip automatic reinvoicing of expense lines, when needed
    res = super()._sale_can_be_reinvoice()
    if self.expense_id:
        return self.expense_id.product_id.expense_mode != "manual" and res
    return res

This already exists in the diff and is correct. The fix is already in place.


3. Additional Code Issues

  • In hr_expense.py, the _compute_manual_reinvoice method assumes that fields.first(rec.analytic_line_ids) always returns a record. If there are no analytic lines, this could raise an error. It should be guarded:

    # In sale_expense_manual_reinvoice/models/hr_expense.py, line ~37
    def _compute_manual_reinvoice(self):
        for rec in self:
            first_line = fields.first(rec.analytic_line_ids)
            for fname in ["manual_reinvoice", "manual_reinvoice_done", "manual_reinvoice_discarded"]:
                rec[fname] = first_line[fname] if first_line else False
  • In account_analytic_line.py, the _compute_manual_reinvoice_done method uses rec.so_line but does not ensure so_line is properly set or exists. This could cause issues if the sale line is not created or is invalid.


4. Test Improvements

To improve test coverage, add the following test cases using TransactionCase or SavepointCase:

a. Test manual_reinvoice field behavior

  • Create an expense with expense_mode = "manual" and verify that manual_reinvoice is set correctly.
  • Create an expense with expense_mode = "auto" and verify that manual_reinvoice is False.

b. Test action_manual_reinvoice method

  • Test that calling action_manual_reinvoice() on a line with manual_reinvoice = False raises UserError.
  • Test that calling action_manual_reinvoice() on a line already re-invoiced raises UserError.
  • Test successful reinvoice of a manual expense line.

c. Test _sale_can_be_reinvoice override

  • Ensure that when expense_id.product_id.expense_mode == "manual", the method returns False.
  • Ensure that when expense_id.product_id.expense_mode == "auto", the method returns the parent result.

d. Test manual_reinvoice_discarded behavior

  • Test that expenses marked as discarded are hidden from the "Expenses to Reinvoice" list.
  • Test that discarded expenses can be un-discarded.

e. Test hr_expense compute fields

  • Test that manual_reinvoice, manual_reinvoice_done, and manual_reinvoice_discarded are computed correctly from related analytic_line_ids.

Use tagged tests for better organization:

@tagged('post_install', 'manual_reinvoice')
def test_manual_reinvoice_flow(self):
    ...

Summary

The test failure is due to a database connection issue in the test environment, not a code bug. The module code is mostly solid, but minor robustness improvements are suggested in hr_expense.py and account_analytic_line.py. Add tests for edge cases and override behavior to ensure full coverage.


⚠️ PR Aging Alert: CRITICAL

This PR by @MarwanBHL has been waiting for 355 days — that is over 11 months without being merged or closed.
🔴 Zero human reviews in 355 days. This contributor invested their time to improve this module. The PSC owes them at least a response — even a "needs changes" is better than silence.
💤 Last activity was 70 days ago.

Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)


Reciprocal Review Request

Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):

My open PRs across OCA:

Reviewing each other's work helps the whole community move forward. Thank you!


Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b

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.

10 participants