[FIX] hr_recruitment: handle key error in calendar.event object

When users try to apply for new job positions from the calendar view,
a traceback will occur.

Steps to reproduce:
- Install the "hr_recruitment" module.
- Go to the "Recruitment" icon; Kanban view will open;
choose any job position; and click on the "NEW APPLICATIONS" button.
- Then, select the "calendar" view and try to create a new record.
After that, a traceback error will occur.

Error:  KeyError: 'default_partner_ids'

When users try to apply for new job positions from the calendar view and
the 'default_partner_ids' key does not exist in the context dictionary,
a traceback occurs.
Code reference:
https://github.com/odoo/odoo/blob/16.0/addons/hr_recruitment/models/calendar.py#L18

sentry-4462451583

closes odoo/odoo#136585

X-original-commit: 851c9fde8e73f30a164c81153e43160f95af6b0a
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
This commit is contained in:
prye-odoo
2023-09-27 17:41:05 +00:00
parent e4fc2ec5e3
commit 14bcc336e4
+3 -3
View File
@@ -14,9 +14,9 @@ class CalendarEvent(models.Model):
self = self.with_context(
default_res_model='hr.applicant', #res_model seems to be lost without this
default_res_model_id=self.env.ref('hr_recruitment.model_hr_applicant').id,
default_res_id=self.env.context['default_applicant_id'],
default_partner_ids=self.env.context['default_partner_ids'],
default_name=self.env.context['default_name']
default_res_id=self.env.context.get('default_applicant_id'),
default_partner_ids=self.env.context.get('default_partner_ids'),
default_name=self.env.context.get('default_name')
)
defaults = super(CalendarEvent, self).default_get(fields)