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

18 lines
601 B
Python
Raw Normal View History

2016-10-19 17:43:51 +05:30
from __future__ import unicode_literals
import frappe
def execute():
2016-11-08 18:18:40 +05:30
frappe.reload_doctype('User')
2016-10-19 17:43:51 +05:30
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 18:18:40 +05:30
employee.db_update()