Fix non english desktop icon labels

This commit is contained in:
Nabin Hait 2017-04-11 18:16:57 +05:30
parent 7dd4e1ae96
commit 0dda08f032
2 changed files with 34 additions and 0 deletions

View file

@ -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

View file

@ -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