Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.3 kB
2
Indexable
Never
if attendance.check_out and self.env.company.checkout_time:
            # Convert times to datetime objects for comparison
            company_checkout_time = fields.Datetime.from_string(self.env.company.checkout_time)
            employee_checkout_time = fields.Datetime.from_string(attendance.check_out)

            # Check if the employee checked out later than the company checkout time
            if employee_checkout_time > company_checkout_time:
                late_checkout_duration = employee_checkout_time - company_checkout_time

                # Convert the late checkout duration to hours and minutes
                late_checkout_hours = late_checkout_duration.total_seconds() / 3600
                total_minutes = int(round(late_checkout_hours * 60))
                hours = total_minutes // 60
                minutes = total_minutes % 60

                # Update the display and float fields
                attendance.late_checkout_display = f'{hours:02d}:{minutes:02d}'
                attendance.late_checkout_hrs = late_checkout_hours
            else:
                attendance.late_checkout_display = '00:00'
                attendance.late_checkout_hrs = 0.0
        else:
            attendance.late_checkout_display = '00:00'
            attendance.late_checkout_hrs = 0.0
Leave a Comment