Merged language patch with global_defaults_to_system_settings patch

This commit is contained in:
Nabin Hait 2014-05-15 17:17:58 +05:30
parent d0a915c47a
commit 9419575126
2 changed files with 22 additions and 5 deletions

View File

@ -4,6 +4,7 @@ erpnext.patches.v4_0.validate_v3_patch
erpnext.patches.v4_0.update_user_properties
erpnext.patches.v4_0.move_warehouse_user_to_restrictions
erpnext.patches.v4_0.new_permissions
erpnext.patches.v4_0.global_defaults_to_system_settings
erpnext.patches.v4_0.update_incharge_name_to_sales_person_in_maintenance_schedule
execute:frappe.reload_doc('accounts', 'doctype', 'sales_invoice') # 2014-01-29
execute:frappe.reload_doc('selling', 'doctype', 'sales_order') # 2014-01-29
@ -42,4 +43,4 @@ execute:frappe.delete_doc_if_exists("DocType", "Warehouse User")
execute:frappe.db.sql("delete from `tabWebsite Item Group` where ifnull(item_group, '')=''")
execute:frappe.delete_doc("Print Format", "SalesInvoice")
execute:import frappe.defaults;frappe.defaults.clear_default("price_list_currency")
erpnext.patches.v4_0.global_defaults_to_system_settings

View File

@ -4,14 +4,30 @@
from __future__ import unicode_literals
import frappe
from collections import Counter
from frappe.core.doctype.user.user import STANDARD_USERS
def execute():
system_settings = frappe.get_doc("System Settings")
# set values from global_defauls
global_defauls = frappe.db.get_value("Global Defaults", None,
["time_zone", "date_format", "number_format", "float_precision", "session_expiry"])
if global_defauls:
system_settings = frappe.get_doc("System Settings")
for key, val in global_defauls.items():
system_settings[key] = val
system_settings.ignore_mandatory = True
system_settings.save()
if not system_settings.get(key):
system_settings[key] = val
# language
if not system_settings.get("language"):
# find most common language
lang = frappe.db.sql_list("""select language from `tabUser`
where ifnull(language, '')!='' and language not like "Loading%%" and name not in ({standard_users})""".format(
standard_users=", ".join(["%s"]*len(STANDARD_USERS))), tuple(STANDARD_USERS))
lang = Counter(lang).most_common(1)
lang = (len(lang) > 0) and lang[0][0] or "english"
system_settings.language = lang
system_settings.save()