From 7624e7bf85912e9f0a2b8af093e80e4059a66f53 Mon Sep 17 00:00:00 2001 From: Ranjith Kurungadam Date: Wed, 18 Oct 2017 15:48:12 +0530 Subject: [PATCH] [hot-fix] sql getting translated (#11243) * fix remove _ in frappe.sql * use %s replacement for sql --- erpnext/healthcare/doctype/consultation/consultation.py | 2 +- erpnext/healthcare/doctype/lab_test/lab_test.py | 4 ++-- erpnext/healthcare/doctype/patient/patient.py | 4 ++-- .../doctype/patient_appointment/patient_appointment.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/erpnext/healthcare/doctype/consultation/consultation.py b/erpnext/healthcare/doctype/consultation/consultation.py index b8155b9b49..e16c22176c 100755 --- a/erpnext/healthcare/doctype/consultation/consultation.py +++ b/erpnext/healthcare/doctype/consultation/consultation.py @@ -78,7 +78,7 @@ def create_invoice(company, patient, physician, consultation_id): create_invoice_items(physician, sales_invoice, company) sales_invoice.save(ignore_permissions=True) - frappe.db.sql(_("""update tabConsultation set invoice='{0}' where name='{1}'""").format(sales_invoice.name, consultation_id)) + frappe.db.sql("""update tabConsultation set invoice=%s where name=%s""", (sales_invoice.name, consultation_id)) appointment = frappe.db.get_value("Consultation", consultation_id, "appointment") if appointment: frappe.db.set_value("Patient Appointment", appointment, "sales_invoice", sales_invoice.name) diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py index 0daf9cba73..6fd9535ecc 100644 --- a/erpnext/healthcare/doctype/lab_test/lab_test.py +++ b/erpnext/healthcare/doctype/lab_test/lab_test.py @@ -291,5 +291,5 @@ def create_invoice(company, patient, lab_tests, prescriptions): @frappe.whitelist() def get_lab_test_prescribed(patient): - return frappe.db.sql(_("""select cp.name, cp.test_code, cp.parent, cp.invoice, ct.physician, ct.consultation_date from tabConsultation ct, - `tabLab Prescription` cp where ct.patient='{0}' and cp.parent=ct.name and cp.test_created=0""").format(patient)) + return frappe.db.sql("""select cp.name, cp.test_code, cp.parent, cp.invoice, ct.physician, ct.consultation_date from tabConsultation ct, + `tabLab Prescription` cp where ct.patient=%s and cp.parent=ct.name and cp.test_created=0""", (patient)) diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py index 98526cc027..f4d9a43ea3 100644 --- a/erpnext/healthcare/doctype/patient/patient.py +++ b/erpnext/healthcare/doctype/patient/patient.py @@ -111,10 +111,10 @@ def make_invoice(patient, company): @frappe.whitelist() def get_patient_detail(patient, company=None): - patient_dict = frappe.db.sql(_("""select * from tabPatient where name='{0}'""").format(patient), as_dict=1) + patient_dict = frappe.db.sql("""select * from tabPatient where name=%s""", (patient), as_dict=1) if not patient_dict: frappe.throw("Patient not found") - vital_sign = frappe.db.sql(_("""select * from `tabVital Signs` where patient='{0}' order by signs_date desc limit 1""").format(patient), as_dict=1) + vital_sign = frappe.db.sql("""select * from `tabVital Signs` where patient=%s order by signs_date desc limit 1""", (patient), as_dict=1) details = patient_dict[0] if vital_sign: diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py index eab2f2d004..2647034f78 100755 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py @@ -125,7 +125,7 @@ def create_invoice(company, physician, patient, appointment_id, appointment_date create_invoice_items(appointment_id, physician, company, sales_invoice) sales_invoice.save(ignore_permissions=True) - frappe.db.sql(_("""update `tabPatient Appointment` set sales_invoice='{0}' where name='{1}'""").format(sales_invoice.name, appointment_id)) + frappe.db.sql("""update `tabPatient Appointment` set sales_invoice=%s where name=%s""", (sales_invoice.name, appointment_id)) frappe.db.set_value("Fee Validity", fee_validity.name, "ref_invoice", sales_invoice.name) consultation = frappe.db.exists({ "doctype": "Consultation",