From 1c9eccce006fa3892a8758b650c9081b2b5a57c8 Mon Sep 17 00:00:00 2001 From: "Sina Chaichi Maleki (cmsi)" Date: Wed, 20 Sep 2023 10:51:16 +0200 Subject: [PATCH] [FIX] hr_holidays: avoid user error in holiday summary report via studio Previously, creating a new report for the time off summary using studio would lead to a user error. This commit addresses the issue by ensuring that if there is no form data, the existing data is returned. Task-3463512 closes odoo/odoo#135978 Signed-off-by: Yannick Tivisse (yti) --- .../report/holidays_summary_report.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/addons/hr_holidays/report/holidays_summary_report.py b/addons/hr_holidays/report/holidays_summary_report.py index bd81a563261..478da0c2c5a 100644 --- a/addons/hr_holidays/report/holidays_summary_report.py +++ b/addons/hr_holidays/report/holidays_summary_report.py @@ -146,18 +146,23 @@ class HrHolidaySummaryReport(models.AbstractModel): @api.model def _get_report_values(self, docids, data=None): - if not data.get('form'): - raise UserError(_("Form content is missing, this report cannot be printed.")) holidays_report = self.env['ir.actions.report']._get_report_from_name('hr_holidays.report_holidayssummary') holidays = self.env['hr.leave'].browse(self.ids) + if data and data.get('form'): + return { + 'doc_ids': self.ids, + 'doc_model': holidays_report.model, + 'docs': holidays, + 'get_header_info': self._get_header_info(data['form']['date_from'], data['form']['holiday_type']), + 'get_day': self._get_day(data['form']['date_from']), + 'get_months': self._get_months(data['form']['date_from']), + 'get_data_from_report': self._get_data_from_report(data['form']), + 'get_holidays_status': self._get_holidays_status(data['form']), + } + return { 'doc_ids': self.ids, 'doc_model': holidays_report.model, - 'docs': holidays, - 'get_header_info': self._get_header_info(data['form']['date_from'], data['form']['holiday_type']), - 'get_day': self._get_day(data['form']['date_from']), - 'get_months': self._get_months(data['form']['date_from']), - 'get_data_from_report': self._get_data_from_report(data['form']), - 'get_holidays_status': self._get_holidays_status(data['form']), + 'docs': holidays }