refactor: use `get_value` instead of `exists`
diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
index 2b88fe7..d782cc2 100644
--- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
+++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.py
@@ -485,14 +485,13 @@
"payment_account": pay.account,
}, ["name"])
- args = {
- 'doctype': 'Payment Request',
+ filters = {
'reference_doctype': 'POS Invoice',
'reference_name': self.name,
'payment_gateway_account': payment_gateway_account,
'email_to': self.contact_mobile
}
- pr = frappe.db.exists(args)
+ pr = frappe.db.get_value('Payment Request', filters=filters)
if pr:
return frappe.get_doc('Payment Request', pr)
diff --git a/erpnext/crm/doctype/appointment/appointment.py b/erpnext/crm/doctype/appointment/appointment.py
index c36faaf..88a9c10 100644
--- a/erpnext/crm/doctype/appointment/appointment.py
+++ b/erpnext/crm/doctype/appointment/appointment.py
@@ -225,9 +225,7 @@
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
diff --git a/erpnext/crm/doctype/appointment/test_appointment.py b/erpnext/crm/doctype/appointment/test_appointment.py
index 7183737..776e604 100644
--- a/erpnext/crm/doctype/appointment/test_appointment.py
+++ b/erpnext/crm/doctype/appointment/test_appointment.py
@@ -8,7 +8,7 @@
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_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",
diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py
index e01bdf6..db4cbb7 100644
--- a/erpnext/hr/doctype/leave_application/test_leave_application.py
+++ b/erpnext/hr/doctype/leave_application/test_leave_application.py
@@ -931,10 +931,7 @@
dept_doc.save(ignore_permissions=True)
def get_leave_period():
- leave_period_name = frappe.db.exists({
- "doctype": "Leave Period",
- "company": "_Test Company"
- })
+ leave_period_name = frappe.db.get_value("Leave Period", {"company": "_Test Company"})
if leave_period_name:
return frappe.get_doc("Leave Period", leave_period_name)
else: