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

19 lines
648 B
Python
Raw Normal View History

2016-10-19 12:13:51 +00:00
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()