Skip to content

Commit

Permalink
[FIX] hr_contract: Fix departure date in case of open contracts
Browse files Browse the repository at this point in the history
Purpose
=======

Take the last expired contract end date if there is not open contract
for the related employee.

closes #156265

Taskid: 3610709
X-original-commit: c6ddecc
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
  • Loading branch information
arpi-odoo authored and tivisse committed Mar 5, 2024
1 parent 687fc48 commit 047721b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion addons/hr_contract/wizard/hr_departure_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class HrDepartureWizard(models.TransientModel):
_inherit = 'hr.departure.wizard'

def _get_employee_departure_date(self):
expired_contract = self.env['hr.contract'].search([('employee_id', '=', self.env.context['active_id']), ('state', '=', 'close')], limit=1, order='date_end desc')
employee = self.env['hr.employee'].browse(self.env.context['active_id'])
if employee.contract_id.state == "open":
return False
expired_contract = self.env['hr.contract'].search([('employee_id', '=', employee.id), ('state', '=', 'close')], limit=1, order='date_end desc')
if expired_contract:
return expired_contract.date_end
return super()._get_employee_departure_date()
Expand Down

0 comments on commit 047721b

Please sign in to comment.