From 14bcc336e49b0529162b2f61b0139280d092ada7 Mon Sep 17 00:00:00 2001 From: prye-odoo Date: Tue, 12 Sep 2023 18:20:52 +0530 Subject: [PATCH] [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) --- addons/hr_recruitment/models/calendar.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_recruitment/models/calendar.py b/addons/hr_recruitment/models/calendar.py index 3ee51623081..3ada239876e 100644 --- a/addons/hr_recruitment/models/calendar.py +++ b/addons/hr_recruitment/models/calendar.py @@ -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)