def update_list_settings(self): # update list settings if new search list_settings = json.loads(get_list_settings(self.doctype) or '{}') list_settings['filters'] = self.filters list_settings['limit'] = self.limit_page_length list_settings['order_by'] = self.order_by if self.save_list_settings_fields: list_settings['fields'] = self.list_settings_fields update_list_settings(self.doctype, list_settings)
def execute(): create_list_settings_table() for user in frappe.db.get_all('User', {'user_type': 'System User'}): defaults = frappe.defaults.get_defaults_for(user.name) for key, value in defaults.iteritems(): if key.startswith('_list_settings:'): doctype = key.replace('_list_settings:', '') columns = ['`tab{1}`.`{0}`'.format(*c) for c in json.loads(value)] update_list_settings(doctype, {'fields': columns})
def update_list_settings(self): # update list settings if new search if not cint(self.limit_start) or cint(self.limit_page_length) != 20: list_settings = { 'filters': self.filters, 'limit': self.limit_page_length, 'order_by': self.order_by } if self.save_list_settings_fields: list_settings['fields'] = self.fields update_list_settings(self.doctype, list_settings)
def get(): args = get_form_params() save_list_settings_fields = False if args.save_list_settings_fields: save_list_settings_fields = True del args['save_list_settings_fields'] data = compress(execute(**args)) # update list settings if new search if not cint(args.limit_start) or cint(args.limit or args.limit_page_length) != 20: list_settings = { 'filters': args.filters, 'limit': args.limit or args.limit_page_length, 'order_by': args.order_by } if save_list_settings_fields: list_settings['fields'] = args.fields update_list_settings(args.doctype, list_settings) return data
def update_dashboard_settings(doctype, dashboard_age_fieldname, dashboard_age_value): list_settings = json.loads(get_list_settings(doctype) or '{}') list_settings['dashboard_age_fieldname'] = dashboard_age_fieldname list_settings['dashboard_age_value'] = dashboard_age_value update_list_settings(doctype, list_settings)