[16.0][FIX] hr_expense_invoice: Delete the lines that are already invoiced when creating the bill values#307
[16.0][FIX] hr_expense_invoice: Delete the lines that are already invoiced when creating the bill values#307dtec-landoo wants to merge 3 commits intoOCA:16.0from
Conversation
…oiced when creating the bill values
…oiced when creating the bill values 2.0
…oiced when creating the bill values 3.0
|
@rafaelbn Hi, I need some review please. Thanks! |
|
@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? |
|
It seems your changes are affecting the module |
|
@kittiu Hi, how can i rerun the tests? Is it possible or you need to do that? |
|
Hello @dtec-landoo , Could you please rebase? So I could test it please. Thank you! |
|
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. |
marcos-mendez
left a comment
There was a problem hiding this comment.
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 retThis 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_valsoverride 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_idsis empty - When
expense_line_idscontains lines with and withoutinvoice_id - Ensure
line_idsare 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 setUse 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:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
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
Fixes #302
This PR solves the issue where expenses are duplicated when they are already linked to an invoice.