diff --git a/frappe/model/utils/list_settings.py b/frappe/model/utils/list_settings.py index 1e1948d008..0f6b91359e 100644 --- a/frappe/model/utils/list_settings.py +++ b/frappe/model/utils/list_settings.py @@ -5,19 +5,28 @@ def get_list_settings(doctype, for_update=False): '{0}::{1}'.format(doctype, frappe.session.user)) if list_settings is None: - list_settings = frappe.db.sql('''select * from __ListSettings - where user=%s and doctype=%s''', (frappe.session.user, doctype), as_dict=True) - list_settings = list_settings and list_settings[0] or '{}' + list_settings = frappe.db.sql('''select data from __ListSettings + where user=%s and doctype=%s''', (frappe.session.user, doctype)) + list_settings = list_settings and list_settings[0][0] or '{}' if not for_update: - update_list_settings(doctype, list_settings) + update_list_settings(doctype, list_settings, True) return list_settings -def update_list_settings(doctype, list_settings): +def update_list_settings(doctype, list_settings, for_update=False): '''update list settings in cache''' - current = json.loads(get_list_settings(doctype, for_update = True)) - current.update(list_settings) + + if for_update: + current = json.loads(list_settings) + else: + current = json.loads(get_list_settings(doctype, for_update = True)) + + if isinstance(current, basestring): + # corrupt due to old code, remove this in a future release + current = {} + + current.update(list_settings) frappe.cache().hset('_list_settings', '{0}::{1}'.format(doctype, frappe.session.user), json.dumps(current))