From 0dda08f0322c8cfdec424aae96d04db8eb2d08b9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 11 Apr 2017 18:16:57 +0530 Subject: [PATCH] Fix non english desktop icon labels --- frappe/patches.txt | 1 + .../v8_0/fix_non_english_desktop_icons.py | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 frappe/patches/v8_0/fix_non_english_desktop_icons.py diff --git a/frappe/patches.txt b/frappe/patches.txt index 39789001be..4ea2400bbd 100644 --- a/frappe/patches.txt +++ b/frappe/patches.txt @@ -175,3 +175,4 @@ frappe.patches.v8_0.setup_email_inbox #2017-03-29 frappe.patches.v8_0.newsletter_childtable_migrate execute:frappe.db.sql("delete from `tabDesktop Icon` where module_name='Communication'") execute:frappe.db.sql("update `tabDesktop Icon` set type='list' where _doctype='Communication'") +frappe.patches.v8_0.fix_non_english_desktop_icons \ No newline at end of file diff --git a/frappe/patches/v8_0/fix_non_english_desktop_icons.py b/frappe/patches/v8_0/fix_non_english_desktop_icons.py new file mode 100644 index 0000000000..f2e01ede4e --- /dev/null +++ b/frappe/patches/v8_0/fix_non_english_desktop_icons.py @@ -0,0 +1,33 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals +import frappe +from frappe.desk.doctype.desktop_icon.desktop_icon import clear_desktop_icons_cache + +def execute(): + desktop_icons = frappe.db.sql(""" + select name, label + from + `tabDesktop Icon` + where + _doctype is not null + and _doctype != '' + and _doctype != label""", as_dict=1) + + for d in desktop_icons: + if not is_english(d.label): + frappe.db.sql("""update `tabDesktop Icon` + set module_name=_doctype, label=_doctype where name=%s""", d.name) + + clear_desktop_icons_cache() + + +def is_english(s): + try: + s.decode('ascii') + except (UnicodeDecodeError, UnicodeEncodeError): + return False + else: + return True \ No newline at end of file