brotherton-erpnext/erpnext/patches/v7_1/set_prefered_contact_email.py

18 lines
601 B
Python
Raw Normal View History

2016-10-19 12:13:51 +00:00
from __future__ import unicode_literals
import frappe
def execute():
2016-11-08 12:48:40 +00:00
frappe.reload_doctype('User')
2016-10-19 12:13:51 +00:00
for d in frappe.get_all("Employee"):
employee = frappe.get_doc("Employee", d.name)
if employee.company_email:
employee.prefered_contact_email = "Company Email"
employee.prefered_email = employee.company_email
elif employee.personal_email:
employee.prefered_contact_email = "Personal Email"
employee.prefered_email = employee.personal_email
elif employee.user_id:
employee.prefered_contact_email = "User ID"
employee.prefered_email = employee.user_id
2016-11-08 12:48:40 +00:00
employee.db_update()