Hello everyone,
I am trying to implement attendance and have encountered a niggle. In my company, some staff go for fieldwork for about 2 months and it would be impractical to only mark attendance retrospectively. I would like to be able to mark attendance for future dates, similar to how leave applications can mark attendance for future dates. Although I am still learning the ropes with Python, I have singled out the line that is throwing the error.
if self.status != 'On Leave' and not self.leave_application and getdate(self.attendance_date) > getdate(nowdate()):
frappe.throw(_("Attendance can not be marked for future dates"))
Can I go ahead and comment this out? Is there a better way to achieve this?
Thank you!
On my test environment, commenting out the validation works. However, on the attendance request doctype, I can’t find the line throwing the error “Future dates not allowed”. I have checked both the .py and .js file extensively. Please I need help
Thank you @abrarpv97,
I was able to override the class of the attendance doctype. However, the method “validate_dates” does not belong to a class and I have not found a way to override that. Can you point me in the right direction, please?
I tried this. Before overriding, I was not able to save future dates. After overriding, I was able to save future dates but the error came on again when I tried to submit the form. I even tried to directly edit the attendance_request.py to remove the validate method on my test bed but it kept throwing the same error
So I had done this already, this was actually my first course of action. I can confirm that it is no more throwing the error. The error is certainly coming from “validate_dates” on the utils.py file. As the function does not belong to a class, I still have not found a way to override it. How do I override the function?
Another problem I have encountered, I have to stop the system from marking attendance as absent (I would like it to continue to mark as present hourly as it is doing) until a certain day (25th of every month by 10pm, I can create a cron job to do this). I have looked though attendance.py and shift.py and it seems the function (mark_absent_for_dates_with_no_attendance) is the only function that I have to override. How can I go about it?