Attendance Request - half day check is enabled
This commit is contained in:
parent
ead858b4de
commit
f5e67213fd
@ -3,7 +3,12 @@
|
|||||||
cur_frm.add_fetch('employee', 'company', 'company');
|
cur_frm.add_fetch('employee', 'company', 'company');
|
||||||
|
|
||||||
frappe.ui.form.on('Attendance Request', {
|
frappe.ui.form.on('Attendance Request', {
|
||||||
refresh: function(frm) {
|
half_day: function(frm) {
|
||||||
|
if(frm.doc.half_day == 1){
|
||||||
|
frm.set_df_property('half_day_date', 'reqd', true);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
frm.set_df_property('half_day_date', 'reqd', false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -145,19 +145,18 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fieldname": "reason",
|
"fieldname": "half_day",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Check",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Reason",
|
"label": "Half Day",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Work From Home\nOn Duty",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -165,7 +164,39 @@
|
|||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"depends_on": "half_day",
|
||||||
|
"fieldname": "half_day_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Half Day Date",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
@ -232,6 +263,38 @@
|
|||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "reason",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Reason",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"options": "Work From Home\nOn Duty",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 1,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -306,7 +369,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-04-19 16:56:23.758754",
|
"modified": "2018-05-14 18:18:56.936880",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Attendance Request",
|
"name": "Attendance Request",
|
||||||
|
|||||||
@ -4,14 +4,18 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import date_diff, add_days
|
from frappe.utils import date_diff, add_days, getdate
|
||||||
from erpnext.hr.doctype.employee.employee import is_holiday
|
from erpnext.hr.doctype.employee.employee import is_holiday
|
||||||
from erpnext.hr.utils import validate_dates
|
from erpnext.hr.utils import validate_dates
|
||||||
|
|
||||||
class AttendanceRequest(Document):
|
class AttendanceRequest(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
validate_dates(self, self.from_date, self.to_date)
|
validate_dates(self, self.from_date, self.to_date)
|
||||||
|
if self.half_day:
|
||||||
|
if not getdate(self.from_date)<=getdate(self.half_day_date)<=getdate(self.to_date):
|
||||||
|
frappe.throw(_("Half day date should be in between from date and to date"))
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
self.create_attendance()
|
self.create_attendance()
|
||||||
@ -32,7 +36,10 @@ class AttendanceRequest(Document):
|
|||||||
attendance = frappe.new_doc("Attendance")
|
attendance = frappe.new_doc("Attendance")
|
||||||
attendance.employee = self.employee
|
attendance.employee = self.employee
|
||||||
attendance.employee_name = self.employee_name
|
attendance.employee_name = self.employee_name
|
||||||
attendance.status = "Present"
|
if self.half_day and date_diff(getdate(self.half_day_date), getdate(attendance_date)) == 0:
|
||||||
|
attendance.status = "Half Day"
|
||||||
|
else:
|
||||||
|
attendance.status = "Present"
|
||||||
attendance.attendance_date = attendance_date
|
attendance.attendance_date = attendance_date
|
||||||
attendance.company = self.company
|
attendance.company = self.company
|
||||||
attendance.attendance_request = self.name
|
attendance.attendance_request = self.name
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user