feature to set / unset birthday reminders webnotes/erpnext#851

This commit is contained in:
Rushabh Mehta
2013-10-02 16:02:02 +05:30
parent 8c2e4e1e1f
commit ea9f845814
3 changed files with 44 additions and 6 deletions

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import getdate, validate_email_add, cstr
from webnotes.utils import getdate, validate_email_add, cstr, cint
from webnotes.model.doc import make_autoname
from webnotes import msgprint, _
@@ -39,12 +39,12 @@ class DocType:
self.validate_email()
self.validate_status()
self.validate_employee_leave_approver()
self.update_dob_event()
def on_update(self):
if self.doc.user_id:
self.update_user_default()
self.update_profile()
self.update_dob_event()
def update_user_default(self):
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
@@ -155,10 +155,11 @@ class DocType:
raise_exception=InvalidLeaveApproverError)
def update_dob_event(self):
if self.doc.status == "Active" and self.doc.date_of_birth:
if self.doc.status == "Active" and self.doc.date_of_birth \
and not cint(webnotes.conn.get_value("HR Settings", None, "stop_birthday_reminders")):
birthday_event = webnotes.conn.sql("""select name from `tabEvent` where repeat_on='Every Year'
and ref_type='Employee' and ref_name=%s""", self.doc.name)
starts_on = self.doc.date_of_birth + " 00:00:00"
ends_on = self.doc.date_of_birth + " 00:15:00"