From 2a966f26afccae7f45f96007f09c0efb8594c5a3 Mon Sep 17 00:00:00 2001 From: Jamsheer Date: Mon, 15 Oct 2018 14:54:29 +0530 Subject: [PATCH] fix: patch - change healthcare desktop icons (#15683) --- .../v11_0/change_healthcare_desktop_icons.py | 131 ++++++++++-------- 1 file changed, 76 insertions(+), 55 deletions(-) diff --git a/erpnext/patches/v11_0/change_healthcare_desktop_icons.py b/erpnext/patches/v11_0/change_healthcare_desktop_icons.py index ab10c66bc4..b1b427559c 100644 --- a/erpnext/patches/v11_0/change_healthcare_desktop_icons.py +++ b/erpnext/patches/v11_0/change_healthcare_desktop_icons.py @@ -1,68 +1,89 @@ import frappe from frappe import _ +change_icons_map = [ + { + "module_name": "Patient", + "color": "#6BE273", + "icon": "fa fa-user", + "doctype": "Patient", + "type": "link", + "link": "List/Patient", + "label": _("Patient") + }, + { + "module_name": "Patient Encounter", + "color": "#2ecc71", + "icon": "fa fa-stethoscope", + "doctype": "Patient Encounter", + "type": "link", + "link": "List/Patient Encounter", + "label": _("Patient Encounter"), + }, + { + "module_name": "Healthcare Practitioner", + "color": "#2ecc71", + "icon": "fa fa-user-md", + "doctype": "Healthcare Practitioner", + "type": "link", + "link": "List/Healthcare Practitioner", + "label": _("Healthcare Practitioner") + }, + { + "module_name": "Patient Appointment", + "color": "#934F92", + "icon": "fa fa-calendar-plus-o", + "doctype": "Patient Appointment", + "type": "link", + "link": "List/Patient Appointment", + "label": _("Patient Appointment") + }, + { + "module_name": "Lab Test", + "color": "#7578f6", + "icon": "octicon octicon-beaker", + "doctype": "Lab Test", + "type": "link", + "link": "List/Lab Test", + "label": _("Lab Test") + } +] + def execute(): change_healthcare_desktop_icons() def change_healthcare_desktop_icons(): - change_icons_map = [ - { - "module_name": "Patient", - "color": "#6BE273", - "icon": "fa fa-user", - "doctype": "Patient", - "type": "link", - "link": "List/Patient", - "label": _("Patient") - }, - { - "module_name": "Patient Encounter", - "color": "#2ecc71", - "icon": "fa fa-stethoscope", - "doctype": "Patient Encounter", - "type": "link", - "link": "List/Patient Encounter", - "label": _("Patient Encounter"), - }, - { - "module_name": "Healthcare Practitioner", - "color": "#2ecc71", - "icon": "fa fa-user-md", - "doctype": "Healthcare Practitioner", - "type": "link", - "link": "List/Healthcare Practitioner", - "label": _("Healthcare Practitioner") - }, - { - "module_name": "Patient Appointment", - "color": "#934F92", - "icon": "fa fa-calendar-plus-o", - "doctype": "Patient Appointment", - "type": "link", - "link": "List/Patient Appointment", - "label": _("Patient Appointment") - }, - { - "module_name": "Lab Test", - "color": "#7578f6", - "icon": "octicon octicon-beaker", - "doctype": "Lab Test", - "type": "link", - "link": "List/Lab Test", - "label": _("Lab Test") - } - ] - for spec in change_icons_map: frappe.db.sql(""" - update `tabDesktop Icon` - set module_name = '{0}', color = '{1}', icon = '{2}', _doctype = '{3}', type = '{4}', - link = '{5}', label = '{6}' - where _doctype = '{7}' - """.format(spec['module_name'], spec['color'], spec['icon'], spec['doctype'], spec['type'], spec['link'], spec['label'], spec['doctype'])) + delete from `tabDesktop Icon` + where _doctype = '{0}' + """.format(spec['doctype'])) + + desktop_icon = frappe.new_doc("Desktop Icon") + desktop_icon.hidden = 1 + desktop_icon.standard = 1 + desktop_icon.icon = spec['icon'] + desktop_icon.color = spec['color'] + desktop_icon.module_name = spec['module_name'] + desktop_icon.label = spec['label'] + desktop_icon.app = "erpnext" + desktop_icon.type = spec['type'] + desktop_icon._doctype = spec['doctype'] + desktop_icon.link = spec['link'] + desktop_icon.save(ignore_permissions=True) frappe.db.sql(""" - update `tabDesktop Icon` - set color = '#FF888B', icon = 'fa fa-heartbeat' + delete from `tabDesktop Icon` where module_name = 'Healthcare' and type = 'module' """) + + desktop_icon = frappe.new_doc("Desktop Icon") + desktop_icon.hidden = 1 + desktop_icon.standard = 1 + desktop_icon.icon = "fa fa-heartbeat" + desktop_icon.color = "#FF888B" + desktop_icon.module_name = "Healthcare" + desktop_icon.label = _("Healthcare") + desktop_icon.app = "erpnext" + desktop_icon.type = 'module' + desktop_icon.save(ignore_permissions=True)