brotherton-erpnext/erpnext/patches/v12_0/set_employee_preferred_emails.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
549 B
Python
Raw Normal View History

import frappe
def execute():
employees = frappe.get_all(
"Employee",
filters={"prefered_email": ""},
fields=["name", "prefered_contact_email", "company_email", "personal_email", "user_id"],
)
for employee in employees:
if not employee.prefered_contact_email:
continue
preferred_email_field = frappe.scrub(employee.prefered_contact_email)
preferred_email = employee.get(preferred_email_field)
frappe.db.set_value(
"Employee", employee.name, "prefered_email", preferred_email, update_modified=False
)