odoo/odoo#199498

Created by fw-bot
Merged at 6f20b8a2dcda5caa30c4a0b63e0586042cbfab53

Statuses:

label
odoo-dev:master-saas-18.1-sentry-6301787988-valueerror-exp_singleton_hr_emp-kkuj-419056-fw
head
3f0b5eef5b8b545f402febc0a0811ef4de4cc3ad
merged
3 months ago by Kishan Kumar Jaiswal (kkuj)
odoo/odoo
saas-18.1 #198088
saas-18.2 #199483
saas-18.3
master #199498

[FW][FIX] hr: prevent error while getting default departure date

Currently, an exception is raised when a user attempts to archive a new employee before saving.

Steps to Reproduce:

  1. Install the HR module.
  2. Navigate to the Employee Module.
  3. Try to archive a new employee before saving.
  4. An error occurs.

Error:
ValueError Expected singleton: hr.employee()

This issue occurs when a user tries to archive a new employee before saving because the system expects a default departure date for the employee, which can't be set properly without saving the employee record first.

[1] -
https://github.com/odoo/odoo/blob/4f58eb9db55c102786010efe3c1fb74edefaf8f3/addons/hr/wizard/hr_departure_wizard.py#L13

This fix resolves the issue by first checking if the employee exists, and then proceeding to find the departure date.

sentry-6301787988


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #198088