brotherton-erpnext/erpnext/patches/v12_0/set_employee_preferred_emails.py
Parth J. Kharwar 8c4cf12c93 Setting preferred driver email in delivery trip (#19832)
* fix: add driver's preferred contact email in delivery trip

* fix: modify driver's preferred email patch and blank field checks

* fix: patch file fix

* fix: patch changes to improve speed

* fix: removal of conflicts

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
2019-12-25 15:14:52 +05:30

17 lines
522 B
Python

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:
preferred_email_field = frappe.scrub(employee.prefered_contact_email)
if not preferred_email_field:
continue
preferred_email = employee.get(preferred_email_field)
frappe.db.set_value("Employee", employee.name, "prefered_email", preferred_email, update_modified=False)