Skip to content
Snippets Groups Projects
Commit 74a7edfe authored by Yannick Tivisse's avatar Yannick Tivisse
Browse files

[FIX] hr: Allow deleting departure reasons


closes odoo/odoo#131285

X-original-commit: 5db1538af8c3381ab7c9006e11db0844d8d365c1
Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
parent 3205cd74
Branches
Tags
No related merge requests found
......@@ -12,6 +12,8 @@ class DepartureReason(models.Model):
sequence = fields.Integer("Sequence", default=10)
name = fields.Char(string="Reason", required=True, translate=True)
# YTI TODO: Move reason_code to hr + adapt _unlink_except_default_departure_reasons
# to use the codes instead of refs
def _get_default_departure_reasons(self):
return {
......@@ -22,4 +24,6 @@ class DepartureReason(models.Model):
@api.ondelete(at_uninstall=False)
def _unlink_except_default_departure_reasons(self):
raise UserError(_('Default departure reasons cannot be deleted.'))
master_reasons = [self.env.ref('hr.departure_fired', False), self.env.ref('hr.departure_resigned', False), self.env.ref('hr.departure_retired', False)]
if any(reason in master_reasons for reason in self):
raise UserError(_('Default departure reasons cannot be deleted.'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment