[UPDT] ATTENDANCE: Additional functions for model WorkRecords
This commit is contained in:
@@ -991,6 +991,27 @@ class WorkRecords(models.Model):
|
||||
last_update = models.DateTimeField(null=True, blank=True)
|
||||
objects = HorillaCompanyManager("employee_id__employee_work_info__company_id")
|
||||
|
||||
def title_message(self):
|
||||
title_message = self.message
|
||||
if title_message == "Absent":
|
||||
if apps.is_installed("leave"):
|
||||
LeaveRequest = get_horilla_model_class(
|
||||
app_label="leave", model="leaverequest"
|
||||
)
|
||||
leave_type = (
|
||||
LeaveRequest.objects.filter(
|
||||
employee_id=self.employee_id,
|
||||
end_date__gte=self.date,
|
||||
start_date__lte=self.date,
|
||||
)
|
||||
.first()
|
||||
.leave_type_id
|
||||
if LeaveRequest.objects.exists()
|
||||
else None
|
||||
)
|
||||
title_message += f" | {leave_type}"
|
||||
return title_message
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.last_update = timezone.now()
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
$(this).closest("select")[0].dispatchEvent(new Event("change"));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
{% if work_record == 'EW' and date <= current_date and not date in leave_dates %}
|
||||
EW
|
||||
{% elif work_record %}
|
||||
<div title="{{work_record.message}}" role="button" class="fw-bold"
|
||||
<div title="{{work_record.title_message}}" role="button" class="fw-bold"
|
||||
onclick="{% if work_record.work_record_type == 'ABS' %}
|
||||
window.location.href=`{% url 'request-view' %}?employee_id={{work_record.employee_id.id}}&from_date={{work_record.date|date:'Y-m-d'}}&to_date={{work_record.date|date:'Y-m-d'}}`;
|
||||
{% else %}
|
||||
|
||||
Reference in New Issue
Block a user