Files
odoo_source/addons/hr_contract/wizard/hr_departure_wizard.py
T
William Braeckman 1aed8b70f5 [IMP] hr: departure wizard
Improve the departure wizard form view aswell as the flow when using it.
Removes the confirmation dialog when archiving an employee to directly
display the departure wizard.
Also changes departure reason to an html field instead of pure text.

Task ID: 2575279

closes odoo/odoo#72367

Related: odoo/enterprise#19116
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-08-03 14:36:02 +00:00

26 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, _
from odoo.exceptions import UserError
class HrDepartureWizard(models.TransientModel):
_inherit = 'hr.departure.wizard'
set_date_end = fields.Boolean(string="Set Contract End Date", default=True,
help="Set the end date on the current contract.")
def action_register_departure(self):
"""If set_date_end is checked, set the departure date as the end date to current running contract,
and cancel all draft contracts"""
current_contract = self.employee_id.contract_id
if current_contract and current_contract.date_start > self.departure_date:
raise UserError(_("Departure date can't be earlier than the start date of current contract."))
super(HrDepartureWizard, self).action_register_departure()
if self.set_date_end:
self.employee_id.contract_ids.filtered(lambda c: c.state == 'draft').write({'state': 'cancel'})
if current_contract:
self.employee_id.contract_id.write({'date_end': self.departure_date})