Conversation
fd8bb70 to
baaf54a
Compare
a6a20c1 to
0406da8
Compare
marcos-mendez
left a comment
There was a problem hiding this comment.
Automated Review -- Tests Failed
1. Root Cause
The test failures are due to incorrect field assignment in contract_contract.py:
employee_work_phoneis not being cleared whenemployee_idis unset (causing assertion failure intest_contract_with_employee_without_email_phone).department_idandjob_idare not being properly reset whenemployee_idis changed to an employee without department/job (causing assertion failures in integration tests).
2. Suggested Fix
In contract_hr/models/contract_contract.py, modify _onchange_employee_id method (around line 56):
@api.onchange("employee_id")
def _onchange_employee_id(self):
"""Update department and job when employee changes"""
if self.employee_id:
self.department_id = self.employee_id.department_id
self.job_id = self.employee_id.job_id
else:
self.department_id = False
self.job_id = False
self.employee_work_phone = False # <-- Add this line3. Additional Code Issues
-
Missing
employee_work_emailreset in_onchange_employee_id: Same issue asemployee_work_phone, should also be cleared whenemployee_idis unset. -
Incorrect
contract_contract_idsdomain inhr_employee.py: The domain usesidwhich is not valid in this context. Should useself.idor remove the domain and rely on inverse field behavior. -
Unnecessary class definition inside
contract_contract.py: The inner classContractLineis not properly defined as a mixin or extension and may cause issues with inheritance or Odoo's registry.
4. Test Improvements
Add the following test cases to cover edge cases:
-
TransactionCase for
test_contract_with_employee_without_email_phone:def test_contract_with_employee_without_email_phone(self): employee = self.env['hr.employee'].create({ 'name': 'Test Employee', 'employee_type': 'freelance', }) contract = self.env['contract.contract'].create({ 'name': 'Test Contract', 'employee_id': employee.id, }) self.assertTrue(contract.employee_work_phone) # Should be set from employee contract.employee_id = False self.assertFalse(contract.employee_work_phone) # Should be cleared
-
SavepointCase for
test_contract_with_employee_department_job_changes:def test_contract_with_employee_department_job_changes(self): employee = self.env['hr.employee'].create({ 'name': 'Test Employee', 'employee_type': 'freelance', 'department_id': self.department.id, 'job_id': self.job.id, }) contract = self.env['contract.contract'].create({ 'name': 'Test Contract', 'employee_id': employee.id, }) self.assertEqual(contract.department_id, self.department) self.assertEqual(contract.job_id, self.job) # Change employee's department and job employee.write({'department_id': False, 'job_id': False}) contract.invalidate_cache() self.assertFalse(contract.department_id) self.assertFalse(contract.job_id)
These tests should be added to test_contract_hr_integration.py and use proper OCA patterns with TransactionCase or SavepointCase as appropriate.
⚠️ PR Aging Alert: CRITICAL
This PR by @mileo has been waiting for 194 days — that is over 6 months without being merged or closed.
🔴 Zero human reviews in 194 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 66 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
This module integrates HR employee management with the contract management system,
designed for managing freelancer and contractor contracts.