diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.json b/erpnext/hr/doctype/hr_settings/hr_settings.json index d8aae66796..09666c5db5 100644 --- a/erpnext/hr/doctype/hr_settings/hr_settings.json +++ b/erpnext/hr/doctype/hr_settings/hr_settings.json @@ -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", diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py index 132c3bd3b9..350ceadccd 100755 --- a/erpnext/hr/doctype/leave_application/leave_application.py +++ b/erpnext/hr/doctype/leave_application/leave_application.py @@ -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):