brotherton-erpnext/erpnext/patches/v7_1/set_prefered_contact_email.py
2016-10-19 18:26:01 +05:30

19 lines
648 B
Python

from __future__ import unicode_literals
import frappe
def execute():
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
employee.flags.ignore_mandatory = True
employee.flags.ignore_validate = True
employee.save()