From 340c80d30a55a75a39cf2433bb36be1f3694b7d8 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Thu, 31 Mar 2022 08:05:44 +0000 Subject: [PATCH] [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) --- addons/hr/models/hr_departure_reason.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/hr/models/hr_departure_reason.py b/addons/hr/models/hr_departure_reason.py index 784695ae022..e84db0f2761 100644 --- a/addons/hr/models/hr_departure_reason.py +++ b/addons/hr/models/hr_departure_reason.py @@ -15,13 +15,11 @@ class DepartureReason(models.Model): def _get_default_departure_reasons(self): return { - 'fired': self.env.ref('hr.departure_fired', False), - 'resigned': self.env.ref('hr.departure_resigned', False), - 'retired': self.env.ref('hr.departure_retired', False), + 'fired': 342, + 'resigned': 343, + 'retired': 340, } @api.ondelete(at_uninstall=False) def _unlink_except_default_departure_reasons(self): - ids = set(map(lambda a: a.id, self._get_default_departure_reasons().values())) - if set(self.ids) & ids: - raise UserError(_('Default departure reasons cannot be deleted.')) + raise UserError(_('Default departure reasons cannot be deleted.'))