Conversation
In such a situation, a queue job is created but crashes. This patch avoids the crash.
1cdc4a7 to
92bafb1
Compare
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root Cause
The test failure is caused by a missing or uninstalled module required by contract_forecast, likely contract or a related dependency. The error occurs during registry loading when Odoo tries to install the contract_forecast module but fails due to an unresolved dependency.
2. Suggested Fix
Ensure that the contract module (or any required dependencies) is included in the depends list of contract_forecast's __manifest__.py. Without this, Odoo cannot resolve the models referenced in contract_line.py.
File: contract_forecast/__manifest__.py
Change: Add 'contract' to the depends list if not already present.
3. Additional Code Issues
-
Potential performance issue in
_generate_forecast_periods:
The code callsrec.forecast_period_ids.unlink()inside a loop without batching. If many contract lines are processed, this may cause performance degradation. However, this is not a bug per se, but a performance consideration. -
No handling of
rec.recurring_next_datebeingFalse:
While the code checksif rec.recurring_next_date:, it doesn't explicitly handle the case whererec.recurring_next_dateisFalseorNone. This is safe due to Python's truthiness, but could be made more explicit for clarity.
4. Test Improvements
Add a TransactionCase or SavepointCase test to cover the following scenarios:
-
Test with a contract line that has no
recurring_next_date- Ensure no error occurs and no forecast periods are created.
-
Test with a contract line that has
recurring_next_dateset- Verify that
forecast_period_idsare properly created or updated.
- Verify that
-
Test with a batch of contract lines (multiple records)
- Ensure
self.exists()prevents processing deleted records.
- Ensure
Example test method (in test_contract_line.py):
def test_generate_forecast_periods_no_recurring_next_date(self):
contract_line = self.env['contract.line'].create({
'name': 'Test Line',
'recurring_next_date': False,
})
contract_line._generate_forecast_periods()
# Assert no forecast periods createdUse @tagged('post_install', 'manual_install') for tests involving module installation dependencies.
⏰ PR Aging Alert
This PR by @fcayre has been open for 179 days (5 months).
💤 Last activity was 87 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:
- 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
In such a situation, a queue job is created but crashes. This patch avoids the crash.