Skip to content

[16.0][FIX] hr_expense_invoice: Delete the lines that are already invoiced when creating the bill values#307

Open
dtec-landoo wants to merge 3 commits intoOCA:16.0from
landoo-es:pr-hr_expense_invoice
Open

[16.0][FIX] hr_expense_invoice: Delete the lines that are already invoiced when creating the bill values#307
dtec-landoo wants to merge 3 commits intoOCA:16.0from
landoo-es:pr-hr_expense_invoice

Conversation

@dtec-landoo
Copy link
Copy Markdown
Contributor

Fixes #302

This PR solves the issue where expenses are duplicated when they are already linked to an invoice.

@dtec-landoo
Copy link
Copy Markdown
Contributor Author

@rafaelbn Hi, I need some review please. Thanks!

@dtec-landoo
Copy link
Copy Markdown
Contributor Author

@rafaelbn @pedrobaeza Hi, I've been looking into why the tests aren't passing, but I can't figure out the reason. Could you please help me?

@pedrobaeza
Copy link
Copy Markdown
Member

It seems your changes are affecting the module hr_expense_advance_clearing, but I haven't dug more.

@dtec-landoo
Copy link
Copy Markdown
Contributor Author

@kittiu Hi, how can i rerun the tests? Is it possible or you need to do that?

@dtec-landoo dtec-landoo closed this Oct 9, 2025
@dtec-landoo dtec-landoo reopened this Oct 9, 2025
@rafaelbn
Copy link
Copy Markdown
Member

Hello @dtec-landoo ,

Could you please rebase? So I could test it please.

Thank you!

@github-actions
Copy link
Copy Markdown

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 Feb 22, 2026
Copy link
Copy Markdown

@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 likely due to a database connection error (Connection to the database failed) during test execution, which is unrelated to the code changes in this PR. This is a CI environment issue, not a bug in the module logic.


2. Suggested Fix

No functional fix is needed for the code changes in this PR. However, to ensure robustness, the _prepare_bill_vals method should guard against potential empty expense_line_ids:

def _prepare_bill_vals(self):
    ret = super(HrExpenseSheet, self)._prepare_bill_vals()
    if self.expense_line_ids:
        ret["line_ids"] = [
            Command.create(expense._prepare_move_line_vals())
            for expense in self.expense_line_ids.filtered(lambda r: not r.invoice_id)
        ]
    return ret

This prevents errors in edge cases where expense_line_ids is empty.


3. Additional Code Issues

  • No real bugs detected in the current diff.
  • The usage of Command.create() is correct and follows Odoo 16.0 patterns.
  • The _prepare_bill_vals override is a valid extension hook and follows OCA conventions.

4. Test Improvements

Add a TransactionCase test to cover the new logic in _prepare_bill_vals, especially:

  • When expense_line_ids is empty
  • When expense_line_ids contains lines with and without invoice_id
  • Ensure line_ids are correctly populated in the bill creation

Example test structure:

from odoo.tests import TransactionCase

class TestHrExpenseSheet(TransactionCase):
    def test_prepare_bill_vals_with_expense_lines(self):
        # Create an expense sheet with expense lines
        sheet = self.env['hr.expense.sheet'].create({...})
        # Call _prepare_bill_vals and assert line_ids are correctly set

Use TransactionCase to test full ORM behavior, and consider tagging with @tag('post_install') if it requires data initialization.


⚠️ PR Aging Alert: CRITICAL

This PR by @dtec-landoo has been waiting for 264 days — that is over 8 months without being merged or closed.
🔴 Zero human reviews in 264 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.

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

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 22, 2026
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.

4 participants