Files
odoo_source/addons/hr/wizard/hr_departure_wizard.py
T
Kevin Baptiste 5f98b6acdb [IMP] hr: add a model for departure reasons
The "Departure Reasons" where hardcoded and couldn't reflect all the
valid departure reasons (like "End Of Fixed-Term Contract").

This commit introduces a new model `hr.departure.reason`.

closes odoo/odoo#66905

Taskid: 2447056
Related: odoo/enterprise#16709
Related: odoo/upgrade#2211
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-03-10 08:32:36 +00:00

31 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class HrDepartureWizard(models.TransientModel):
_name = 'hr.departure.wizard'
_description = 'Departure Wizard'
departure_reason_id = fields.Many2one("hr.departure.reason", default=lambda self: self.env['hr.departure.reason'].search([], limit=1))
departure_description = fields.Text(string="Additional Information")
departure_date = fields.Date(string="Departure Date", required=True, default=fields.Date.today)
employee_id = fields.Many2one(
'hr.employee', string='Employee', required=True,
default=lambda self: self.env.context.get('active_id', None),
)
archive_private_address = fields.Boolean('Archive Private Address', default=True)
def action_register_departure(self):
employee = self.employee_id
employee.departure_reason_id = self.departure_reason_id
employee.departure_description = self.departure_description
employee.departure_date = self.departure_date
if self.archive_private_address:
# ignore contact links to internal users
private_address = employee.address_home_id
if private_address and private_address.active and not self.env['res.users'].search([('partner_id', '=', private_address.id)]):
private_address.toggle_active()