[FIX] hr_contract: Fix departure date in case of open contracts
Purpose ======= Take the last expired contract end date if there is not open contract for the related employee. closes odoo/odoo#156326 Taskid: 3610709 X-original-commit: c6ddecc09361cde4580242dc4f87594e78e51a57 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
committed by
Yannick Tivisse
parent
52d7579435
commit
bd1c5a2699
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user