feature to set / unset birthday reminders webnotes/erpnext#851
This commit is contained in:
parent
8c2e4e1e1f
commit
ea9f845814
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
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.model.doc import make_autoname
|
||||||
from webnotes import msgprint, _
|
from webnotes import msgprint, _
|
||||||
|
|
||||||
@ -39,12 +39,12 @@ class DocType:
|
|||||||
self.validate_email()
|
self.validate_email()
|
||||||
self.validate_status()
|
self.validate_status()
|
||||||
self.validate_employee_leave_approver()
|
self.validate_employee_leave_approver()
|
||||||
|
self.update_dob_event()
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
if self.doc.user_id:
|
if self.doc.user_id:
|
||||||
self.update_user_default()
|
self.update_user_default()
|
||||||
self.update_profile()
|
self.update_profile()
|
||||||
self.update_dob_event()
|
|
||||||
|
|
||||||
def update_user_default(self):
|
def update_user_default(self):
|
||||||
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
|
webnotes.conn.set_default("employee", self.doc.name, self.doc.user_id)
|
||||||
@ -155,10 +155,11 @@ class DocType:
|
|||||||
raise_exception=InvalidLeaveApproverError)
|
raise_exception=InvalidLeaveApproverError)
|
||||||
|
|
||||||
def update_dob_event(self):
|
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'
|
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)
|
and ref_type='Employee' and ref_name=%s""", self.doc.name)
|
||||||
|
|
||||||
starts_on = self.doc.date_of_birth + " 00:00:00"
|
starts_on = self.doc.date_of_birth + " 00:00:00"
|
||||||
ends_on = self.doc.date_of_birth + " 00:15:00"
|
ends_on = self.doc.date_of_birth + " 00:15:00"
|
||||||
|
|
||||||
|
@ -6,6 +6,24 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
|
from webnotes.utils import cint
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
self.original_stop_birthday_reminders = cint(webnotes.conn.get_value("HR Settings",
|
||||||
|
None, "stop_birthday_reminders"))
|
||||||
|
|
||||||
|
def on_update(self):
|
||||||
|
# reset birthday reminders
|
||||||
|
if cint(self.doc.stop_birthday_reminders) != self.original_stop_birthday_reminders:
|
||||||
|
webnotes.conn.sql("""delete from `tabEvent` where repeat_on='Every Year' and ref_type='Employee'""")
|
||||||
|
|
||||||
|
if not self.doc.stop_birthday_reminders:
|
||||||
|
for employee in webnotes.conn.sql_list("""select name from `tabEmployee` where status='Active' and
|
||||||
|
ifnull(date_of_birth, '')!=''"""):
|
||||||
|
webnotes.get_obj("Employee", employee).update_dob_event()
|
||||||
|
|
||||||
|
webnotes.msgprint(webnotes._("Updated Birthday Reminders"))
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-08-02 13:45:23",
|
"creation": "2013-08-02 13:45:23",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-08-02 14:22:26",
|
"modified": "2013-10-02 15:44:38",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -38,6 +38,12 @@
|
|||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"name": "HR Settings"
|
"name": "HR Settings"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "employee_settings",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Employee Settings"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "Employee record is created using selected field. ",
|
"description": "Employee record is created using selected field. ",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
@ -46,6 +52,19 @@
|
|||||||
"label": "Employee Records to be created by",
|
"label": "Employee Records to be created by",
|
||||||
"options": "Naming Series\nEmployee Number"
|
"options": "Naming Series\nEmployee Number"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "Don't send Employee Birthday Reminders",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "stop_birthday_reminders",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Stop Birthday Reminders"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "payroll_settings",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Payroll Settings"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "If checked, Total no. of Working Days will include holidays, and this will reduce the value of Salary Per Day",
|
"description": "If checked, Total no. of Working Days will include holidays, and this will reduce the value of Salary Per Day",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user