diff --git a/excel_report_designer/models/report_excel.py b/excel_report_designer/models/report_excel.py index 7be98878c..aa14f078b 100644 --- a/excel_report_designer/models/report_excel.py +++ b/excel_report_designer/models/report_excel.py @@ -1390,7 +1390,19 @@ class ReportExcel(models.Model): for rec in records: col = 0 for field_name in data['fields_name']: + # 特殊处理:vacation.meal.active 没有 department_id,通过 employee_id 获取 + if field_name == 'department_id' and 'department_id' not in rec._fields: + value = rec.employee_id.department_id.display_name if rec.employee_id and rec.employee_id.department_id else '' + sheet.write(row, col, value, data_format) + col += 1 + continue + field = rec._fields.get(field_name) + if not field: + sheet.write(row, col, '', data_format) + col += 1 + continue + value = rec[field_name] if isinstance(value, datetime.datetime): if value: