preferred email for payroll

This commit is contained in:
robert schouten 2016-09-21 11:16:53 +08:00
parent 5cf5019b89
commit d7721a605d
5 changed files with 86 additions and 5 deletions

View File

@ -40,6 +40,28 @@ erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({
"Ms": "Female"
}[this.frm.doc.salutation]);
}
},
});
frappe.ui.form.on('Employee',{
prefered_contact_email:function(frm){
frm.events.update_contact(frm)
},
personal_email:function(frm){
frm.events.update_contact(frm)
},
company_email:function(frm){
frm.events.update_contact(frm)
},
user_id:function(frm){
frm.events.update_contact(frm)
},
update_contact:function(frm){
for(var i =0, j=frm.fields.length;i<j;i++){
if (frm.fields[i].df.label===frm.doc.prefered_contact_email){
frm.set_value("prefered_email",frm.fields[i].value)
}
}
}
});
cur_frm.cscript = new erpnext.hr.EmployeeController({frm: cur_frm});

View File

@ -3,11 +3,13 @@
"allow_import": 1,
"allow_rename": 1,
"autoname": "naming_series:",
"beta": 0,
"creation": "2013-03-07 09:04:18",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 0,
"fields": [
{
"allow_on_submit": 0,
@ -945,6 +947,59 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"default": "",
"fieldname": "prefered_contact_email",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Prefered Contact Email",
"length": 0,
"no_copy": 0,
"options": "\nCompany Email\nPersonal Email\nUser ID",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "prefered_email",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Prefered Email",
"length": 0,
"no_copy": 0,
"options": "Email",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -1954,7 +2009,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2016-04-04 06:44:59.778649",
"modified": "2016-09-19 16:46:48.432197",
"modified_by": "Administrator",
"module": "HR",
"name": "Employee",
@ -2022,6 +2077,7 @@
"write": 1
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"search_fields": "employee_name",

View File

@ -167,7 +167,7 @@
"bold": 0,
"collapsible": 0,
"default": "1",
"description": "",
"description": "Emails salary slip to employee based on preferred email selected in Employee",
"fieldname": "email_salary_slip_to_employee",
"fieldtype": "Check",
"hidden": 0,
@ -226,7 +226,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
"modified": "2016-08-10 12:32:39.780599",
"modified": "2016-09-21 11:28:50.687129",
"modified_by": "Administrator",
"module": "HR",
"name": "HR Settings",

View File

@ -335,8 +335,8 @@ class SalarySlip(TransactionBase):
self.update_status()
def email_salary_slip(self):
receiver = frappe.db.get_value("Employee", self.employee, "company_email") or \
frappe.db.get_value("Employee", self.employee, "personal_email")
receiver = frappe.db.get_value("Employee", self.employee, "prefered_email")
if receiver:
subj = 'Salary Slip - from {0} to {1}, fiscal year {2}'.format(self.start_date, self.end_date, self.fiscal_year)
frappe.sendmail([receiver], subject=subj, message = _("Please see attachment"),

View File

@ -330,5 +330,8 @@ execute:frappe.db.sql("update `tabTimesheet` ts, `tabEmployee` emp set ts.employ
erpnext.patches.v7_1.update_lead_source
erpnext.patches.v7_1.fix_link_for_customer_from_lead
erpnext.patches.v7_0.update_mode_of_payment_type
execute:frappe.reload_doctype('Employee')
execute:frappe.db.sql("update `tabEmployee` set prefered_contact_email = IFNULL(prefered_contact_email,'') ")
execute:frappe.reload_doctype("Salary Slip")
execute:frappe.db.sql("update `tabSalary Slip` set posting_date=creation")