Skip to content

[16.0] contract_hr#1296

Draft
mileo wants to merge 31 commits intoOCA:16.0from
kmee:16.0-contract-hr
Draft

[16.0] contract_hr#1296
mileo wants to merge 31 commits intoOCA:16.0from
kmee:16.0-contract-hr

Conversation

@mileo
Copy link
Member

@mileo mileo commented Sep 2, 2025

This module integrates HR employee management with the contract management system,
designed for managing freelancer and contractor contracts.

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 failures are due to incorrect field assignment in contract_contract.py:

  • employee_work_phone is not being cleared when employee_id is unset (causing assertion failure in test_contract_with_employee_without_email_phone).
  • department_id and job_id are not being properly reset when employee_id is 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 line

3. Additional Code Issues

  1. Missing employee_work_email reset in _onchange_employee_id: Same issue as employee_work_phone, should also be cleared when employee_id is unset.

  2. Incorrect contract_contract_ids domain in hr_employee.py: The domain uses id which is not valid in this context. Should use self.id or remove the domain and rely on inverse field behavior.

  3. Unnecessary class definition inside contract_contract.py: The inner class ContractLine is 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:

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.

5 participants