Skip to content
Snippets Groups Projects
Commit 7ebe9dcd authored by paso-odoo's avatar paso-odoo
Browse files

[FIX] hr: launch plan for archived employees


Issue 1
=======
When an employee is archived and the user clicks on the 'Launch Plan' button
from that employee, it will throw an IndexError saying the tuple index is out
of range.

Steps to produce:
- Open any Employee > Action > Archive > Apply.
- Open archived employee(s) from the Filters > Archived.
- From list view or form view, Click on the 'Launch Plan' button.
- Error: IndexError: tuple index out of range.

Fixed this issue using the current company if the employee and their company
are not found.

Issue 2
=======
When a user clicks on the 'Launch Plan' button from that employee, It will
throw an IndexError saying the tuple index is out of range.

Steps to produce:
- Open any Employee.
- Make the 'name' field unrequired (Studio or Edit form view).
- Now create a new employee - before clicking on the Save button click on the
'Launch Plan' button.
- Discard Changes > Error will produce.

Fixed this issue using the check before using the employee record.

sentry-4259555464

closes odoo/odoo#125704

Signed-off-by: default avatarSofie Gvaladze (sgv) <sgv@odoo.com>
parent 4fb1d7f7
Branches
Tags
No related merge requests found
......@@ -12,6 +12,8 @@ class HrPlanWizard(models.TransientModel):
def _default_plan_id(self):
# We know that all employees belong to the same company
employees = self.env['hr.employee'].browse(self.env.context.get('active_ids') if self.env.context.get('active_ids') else [])
if not employees:
return None
if len(employees.department_id) > 1:
return self.env['hr.plan'].search([
('company_id', '=', employees[0].company_id.id),
......@@ -50,7 +52,7 @@ class HrPlanWizard(models.TransientModel):
@api.depends('employee_ids')
def _compute_company_id(self):
for wizard in self:
wizard.company_id = wizard.employee_ids[0].company_id
wizard.company_id = wizard.employee_ids and wizard.employee_ids[0].company_id or self.env.company
def _get_warnings(self):
self.ensure_one()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment