Files
odoo_source/addons/hr/models/hr_departure_reason.py
T
Yannick Tivisse 340c80d30a [FIX] hr: Use reason_code on departure.reason
Purpose
=======

Departure reasons could be used on business code (eg: payroll).

Currently the mapping is made based on the xmlid, but it could
happen for some customers to create several departure reasons
of the same kind. (ex: "Resigned - Salary" or even
"Resigned - Personal Reasons").

This commit uses the departure reason on _get_default_departure_reasons
to allow considering them together.

closes odoo/odoo#87662

Taskid: 2811192
X-original-commit: c7f46a4760fa2beb7d50b4b95f10e14a1a326423
Related: odoo/enterprise#25771
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2022-04-05 14:13:58 +02:00

26 lines
766 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import UserError
class DepartureReason(models.Model):
_name = "hr.departure.reason"
_description = "Departure Reason"
_order = "sequence"
sequence = fields.Integer("Sequence", default=10)
name = fields.Char(string="Reason", required=True, translate=True)
def _get_default_departure_reasons(self):
return {
'fired': 342,
'resigned': 343,
'retired': 340,
}
@api.ondelete(at_uninstall=False)
def _unlink_except_default_departure_reasons(self):
raise UserError(_('Default departure reasons cannot be deleted.'))