From 71aaeeafdf40ede772023ba8c83aafcf0cc87f2d Mon Sep 17 00:00:00 2001 From: Horilla Date: Fri, 8 Dec 2023 15:23:30 +0530 Subject: [PATCH] [FIX] ATTENDANCE: Attendance request work type and shift None value issue --- attendance/methods/differentiate.py | 4 ++-- attendance/models.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/attendance/methods/differentiate.py b/attendance/methods/differentiate.py index 2d21e1499..a6ec9997f 100644 --- a/attendance/methods/differentiate.py +++ b/attendance/methods/differentiate.py @@ -84,9 +84,9 @@ def get_diff_dict(first_dict, other_dict, model=None): "%I:%M %p" ) elif isinstance(field, models.ForeignKey): - if value is not None: + if value is not None and len(str(value)): value = field.related_model.objects.get(id=value) - if other_value is not None: + if other_value is not None and len(str(other_value)): other_value = field.related_model.objects.get(id=other_value) difference[verb_key] = (value, other_value) return difference diff --git a/attendance/models.py b/attendance/models.py index 3b17ca3a1..c0cc9270d 100644 --- a/attendance/models.py +++ b/attendance/models.py @@ -323,8 +323,8 @@ class Attendance(models.Model): "attendance_clock_in": str(self.attendance_clock_in), "attendance_clock_out": str(self.attendance_clock_out), "attendance_clock_out_date": str(self.attendance_clock_out_date), - "shift_id": self.shift_id.id, - "work_type_id": self.work_type_id.id, + "shift_id": self.shift_id.id if self.shift_id else "", + "work_type_id": self.work_type_id.id if self.work_type_id else "", "attendance_worked_hour": self.attendance_worked_hour, "minimum_hour": self.minimum_hour, # Add other fields you want to store