From c26bc44b3267c37aa3668236f0fc52a098c43a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Mon, 9 Feb 2026 00:58:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- excel_report_designer/models/report_excel.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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: