From 39eb4e040c759c8c3fdad2d1198943043fc0faf5 Mon Sep 17 00:00:00 2001 From: Chillar Anand Date: Fri, 14 Jan 2022 12:37:32 +0530 Subject: [PATCH] fix(healthcare): Remove custom fields related to healthcare (#29129) Co-authored-by: Rucha Mahabal --- .../patches/v14_0/delete_healthcare_doctypes.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/patches/v14_0/delete_healthcare_doctypes.py b/erpnext/patches/v14_0/delete_healthcare_doctypes.py index 28fc01beab..3a4f8f537d 100644 --- a/erpnext/patches/v14_0/delete_healthcare_doctypes.py +++ b/erpnext/patches/v14_0/delete_healthcare_doctypes.py @@ -47,3 +47,18 @@ def execute(): frappe.delete_doc("DocType", doctype, ignore_missing=True) frappe.delete_doc("Module Def", "Healthcare", ignore_missing=True, force=True) + + custom_fields = { + 'Sales Invoice': ['patient', 'patient_name', 'ref_practitioner'], + 'Sales Invoice Item': ['reference_dt', 'reference_dn'], + 'Stock Entry': ['inpatient_medication_entry'], + 'Stock Entry Detail': ['patient', 'inpatient_medication_entry_child'], + } + for doc, fields in custom_fields.items(): + filters = { + 'dt': doc, + 'fieldname': ['in', fields] + } + records = frappe.get_all('Custom Field', filters=filters, pluck='name') + for record in records: + frappe.delete_doc('Custom Field', record, ignore_missing=True, force=True)