diff --git a/addons/hr_contract/models/hr_employee.py b/addons/hr_contract/models/hr_employee.py index ba1536f4e99..1c4d12c2234 100644 --- a/addons/hr_contract/models/hr_employee.py +++ b/addons/hr_contract/models/hr_employee.py @@ -35,7 +35,7 @@ class Employee(models.Model): contract_ids = fields.One2many('hr.contract', 'employee_id', string='Employee Contracts') contract_id = fields.Many2one( 'hr.contract', string='Current Contract', groups="hr.group_hr_user", - domain="[('company_id', '=', company_id), ('employee_id', '=', id)]", help='Current contract of the employee') + domain="[('company_id', '=', company_id), ('employee_id', '=', id)]", help='Current contract of the employee', copy=False) calendar_mismatch = fields.Boolean(related='contract_id.calendar_mismatch') contracts_count = fields.Integer(compute='_compute_contracts_count', string='Contract Count') contract_warning = fields.Boolean(string='Contract Warning', store=True, compute='_compute_contract_warning', groups="hr.group_hr_user") diff --git a/addons/hr_contract/tests/test_contract.py b/addons/hr_contract/tests/test_contract.py index 5cae97df191..55d9c4545e7 100644 --- a/addons/hr_contract/tests/test_contract.py +++ b/addons/hr_contract/tests/test_contract.py @@ -134,6 +134,11 @@ class TestHrContracts(TestContractCommon): draft_contract.state = 'draft' self.assertEqual(self.employee.contract_id, contract) + def test_copy_employee_contract_create(self): + contract = self.create_contract('open', 'normal', date(2018, 1, 1), date(2018, 1, 2)) + duplicate_employee = self.employee.copy() + self.assertNotEqual(duplicate_employee.contract_id, contract) + def test_check_multi_company_contract_expiration(self): """ Check that the expiration warnings for contracts and work permits are posted based on the res settings.