diff --git a/yuthon_maintain/models/inherit_maintenance_equipment.py b/yuthon_maintain/models/inherit_maintenance_equipment.py index b2aeab175..5353c5d8c 100644 --- a/yuthon_maintain/models/inherit_maintenance_equipment.py +++ b/yuthon_maintain/models/inherit_maintenance_equipment.py @@ -103,6 +103,9 @@ class InheritMaintenanceEquipment(models.Model): # 从第3行开始写入数据(第1-2行是表头) row = 3 + # 设置列宽(A列序号列设置为较窄) + sheet.column_dimensions['A'].width = 6 # 序号列宽度 + # 获取模板样式行(使用第3行作为参考) template_row_idx = 3 if sheet.max_row >= template_row_idx: @@ -170,8 +173,11 @@ class InheritMaintenanceEquipment(models.Model): # I列:设备类别 sheet.cell(row=row, column=9, value=record.category_id.name if record.category_id else '') - # J列:公司 - sheet.cell(row=row, column=10, value=record.company_id.name if record.company_id else '') + # J列:公司(company 字段) + company = '' + if record.company: + company = dict(record._fields['company'].selection).get(record.company, '') + sheet.cell(row=row, column=10, value=company) # 设置最小行高,确保内容显示完整 if not sheet.row_dimensions[row].height or sheet.row_dimensions[row].height < 30: