refactor: use get_value instead of exists

This commit is contained in:
Ankush Menat
2022-03-22 11:44:53 +05:30
committed by Ankush Menat
parent 5c4eabf075
commit f37316a266
4 changed files with 5 additions and 20 deletions

View File

@@ -225,9 +225,7 @@ def _check_agent_availability(agent_email, scheduled_time):
def _get_employee_from_user(user):
employee_docname = frappe.db.exists(
{'doctype': 'Employee', 'user_id': user})
employee_docname = frappe.db.get_value('Employee', {'user_id': user})
if employee_docname:
# frappe.db.exists returns a tuple of a tuple
return frappe.get_doc('Employee', employee_docname)
return None

View File

@@ -8,7 +8,7 @@ import frappe
def create_test_lead():
test_lead = frappe.db.exists({"doctype": "Lead", "email_id": "test@example.com"})
test_lead = frappe.db.get_value("Lead", {"email_id": "test@example.com"})
if test_lead:
return frappe.get_doc("Lead", test_lead)
test_lead = frappe.get_doc(
@@ -19,15 +19,6 @@ def create_test_lead():
def create_test_appointments():
test_appointment = frappe.db.exists(
{
"doctype": "Appointment",
"scheduled_time": datetime.datetime.now(),
"email": "test@example.com",
}
)
if test_appointment:
return frappe.get_doc("Appointment", test_appointment)
test_appointment = frappe.get_doc(
{
"doctype": "Appointment",