Merge pull request #24877 from Anurag810/settings_for_eanbling_leave_notificstion

feat: Add checkbox for disabling leave notification in HR Settings
This commit is contained in:
Anurag Mishra 2021-03-16 13:23:16 +05:30 committed by GitHub
commit 5cc322e01d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -13,6 +13,7 @@
"stop_birthday_reminders",
"expense_approver_mandatory_in_expense_claim",
"leave_settings",
"send_leave_notification",
"leave_approval_notification_template",
"leave_status_notification_template",
"role_allowed_to_create_backdated_leave_application",
@ -69,15 +70,19 @@
"label": "Leave Settings"
},
{
"depends_on": "eval: doc.send_leave_notification == 1",
"fieldname": "leave_approval_notification_template",
"fieldtype": "Link",
"label": "Leave Approval Notification Template",
"mandatory_depends_on": "eval: doc.send_leave_notification == 1",
"options": "Email Template"
},
{
"depends_on": "eval: doc.send_leave_notification == 1",
"fieldname": "leave_status_notification_template",
"fieldtype": "Link",
"label": "Leave Status Notification Template",
"mandatory_depends_on": "eval: doc.send_leave_notification == 1",
"options": "Email Template"
},
{
@ -132,13 +137,19 @@
"fieldname": "automatically_allocate_leaves_based_on_leave_policy",
"fieldtype": "Check",
"label": "Automatically Allocate Leaves Based On Leave Policy"
},
{
"default": "1",
"fieldname": "send_leave_notification",
"fieldtype": "Check",
"label": "Send Leave Notification"
}
],
"icon": "fa fa-cog",
"idx": 1,
"issingle": 1,
"links": [],
"modified": "2021-02-25 12:31:14.947865",
"modified": "2021-03-14 02:04:22.907159",
"modified_by": "Administrator",
"module": "HR",
"name": "HR Settings",

View File

@ -40,7 +40,8 @@ class LeaveApplication(Document):
def on_update(self):
if self.status == "Open" and self.docstatus < 1:
# notify leave approver about creation
self.notify_leave_approver()
if frappe.db.get_single_value("HR Settings", "send_leave_notification"):
self.notify_leave_approver()
def on_submit(self):
if self.status == "Open":
@ -50,7 +51,8 @@ class LeaveApplication(Document):
self.update_attendance()
# notify leave applier about approval
self.notify_employee()
if frappe.db.get_single_value("HR Settings", "send_leave_notification"):
self.notify_employee()
self.create_leave_ledger_entry()
self.reload()
@ -60,7 +62,8 @@ class LeaveApplication(Document):
def on_cancel(self):
self.create_leave_ledger_entry(submit=False)
# notify leave applier about cancellation
self.notify_employee()
if frappe.db.get_single_value("HR Settings", "send_leave_notification"):
self.notify_employee()
self.cancel_attendance()
def validate_applicable_after(self):