Bläddra i källkod

Fix non english desktop icon labels

version-14
Nabin Hait 8 år sedan
förälder
incheckning
0dda08f032
2 ändrade filer med 34 tillägg och 0 borttagningar
  1. +1
    -0
      frappe/patches.txt
  2. +33
    -0
      frappe/patches/v8_0/fix_non_english_desktop_icons.py

+ 1
- 0
frappe/patches.txt Visa fil

@@ -175,3 +175,4 @@ frappe.patches.v8_0.setup_email_inbox #2017-03-29
frappe.patches.v8_0.newsletter_childtable_migrate frappe.patches.v8_0.newsletter_childtable_migrate
execute:frappe.db.sql("delete from `tabDesktop Icon` where module_name='Communication'") 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'") execute:frappe.db.sql("update `tabDesktop Icon` set type='list' where _doctype='Communication'")
frappe.patches.v8_0.fix_non_english_desktop_icons

+ 33
- 0
frappe/patches/v8_0/fix_non_english_desktop_icons.py Visa fil

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

Laddar…
Avbryt
Spara