mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 15:39:20 +00:00
refactor: use common method to get employee contacts
This commit is contained in:
@@ -300,19 +300,9 @@ def complete_contact_details(party_details):
|
|||||||
contact_details = frappe._dict()
|
contact_details = frappe._dict()
|
||||||
|
|
||||||
if party_details.party_type == "Employee":
|
if party_details.party_type == "Employee":
|
||||||
contact_details = frappe.db.get_value(
|
from erpnext.setup.doctype.employee.employee import get_contact_details as get_employee_contact
|
||||||
"Employee",
|
|
||||||
party_details.party,
|
|
||||||
[
|
|
||||||
"employee_name as contact_display",
|
|
||||||
"prefered_email as contact_email",
|
|
||||||
"cell_number as contact_mobile",
|
|
||||||
"designation as contact_designation",
|
|
||||||
"department as contact_department",
|
|
||||||
],
|
|
||||||
as_dict=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
contact_details = get_employee_contact(party_details.party)
|
||||||
contact_details.update({"contact_person": None, "contact_phone": None})
|
contact_details.update({"contact_person": None, "contact_phone": None})
|
||||||
elif party_details.contact_person:
|
elif party_details.contact_person:
|
||||||
contact_details = frappe.db.get_value(
|
contact_details = frappe.db.get_value(
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from frappe.model.naming import set_name_by_naming_series
|
|||||||
from frappe.permissions import (
|
from frappe.permissions import (
|
||||||
add_user_permission,
|
add_user_permission,
|
||||||
get_doc_permissions,
|
get_doc_permissions,
|
||||||
has_permission,
|
|
||||||
remove_user_permission,
|
remove_user_permission,
|
||||||
)
|
)
|
||||||
from frappe.utils import cstr, getdate, today, validate_email_address
|
from frappe.utils import cstr, getdate, today, validate_email_address
|
||||||
@@ -431,6 +430,12 @@ def has_upload_permission(doc, ptype="read", user=None):
|
|||||||
def get_contact_details(employee: str) -> dict:
|
def get_contact_details(employee: str) -> dict:
|
||||||
"""
|
"""
|
||||||
Returns basic contact details for the given employee.
|
Returns basic contact details for the given employee.
|
||||||
|
|
||||||
|
Email is selected based on the following priority:
|
||||||
|
1. Prefered Email
|
||||||
|
2. Company Email
|
||||||
|
3. Personal Email
|
||||||
|
4. User ID
|
||||||
"""
|
"""
|
||||||
if not employee:
|
if not employee:
|
||||||
frappe.throw(msg=_("Employee is required"), title=_("Missing Parameter"))
|
frappe.throw(msg=_("Employee is required"), title=_("Missing Parameter"))
|
||||||
|
|||||||
Reference in New Issue
Block a user