Skip to content

Commit f3a5802

Browse files
committed
fix(ui): handle None values for entry_date and contract_type in employee detail
Fix crash when viewing employee details if entry_date or contract_type are None (now optional fields). Changes: - Add None check for contract_type before displaying - Add None check for entry_date before calling strftime() This prevents the error: "NoneType has no attribute strftime" when viewing employees without entry date or contract type. Fixes crash introduced when making these fields optional.
1 parent 8d464ba commit f3a5802

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/ui_ctk/views/employee_detail.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,15 @@ def create_info_section(self, parent):
160160
self.create_info_row(info_frame, "Statut:", STATUS_ACTIVE if self.employee.is_active else STATUS_INACTIVE)
161161
self.create_info_row(info_frame, "Zone de travail:", self.employee.workspace)
162162
self.create_info_row(info_frame, "Poste:", self.employee.role)
163-
self.create_info_row(info_frame, "Type de contrat:", self.employee.contract_type)
164163

165-
# Entry date
166-
entry_date_str = self.employee.entry_date.strftime(DATE_FORMAT)
167-
self.create_info_row(info_frame, "Date d'entrée:", entry_date_str)
164+
# Contract type (optional)
165+
if self.employee.contract_type:
166+
self.create_info_row(info_frame, "Type de contrat:", self.employee.contract_type)
167+
168+
# Entry date (optional)
169+
if self.employee.entry_date:
170+
entry_date_str = self.employee.entry_date.strftime(DATE_FORMAT)
171+
self.create_info_row(info_frame, "Date d'entrée:", entry_date_str)
168172

169173
# Seniority
170174
seniority_years = self.employee.seniority

0 commit comments

Comments
 (0)