[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) <yti@odoo.com>
This commit is contained in:
Sina Chaichi Maleki (cmsi)
2023-10-12 16:11:58 +00:00
parent adc58cdafe
commit 1c9eccce00
@@ -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
}