@@ -176,9 +176,13 @@ def collect_error_snapshots(): | |||||
def clear_old_snapshots(): | def clear_old_snapshots(): | ||||
"""Clear snapshots that are older than a month""" | """Clear snapshots that are older than a month""" | ||||
from frappe.query_builder import DocType, Interval | |||||
from frappe.query_builder.functions import Now | |||||
frappe.db.sql("""delete from `tabError Snapshot` | |||||
where creation < (NOW() - INTERVAL '1' MONTH)""") | |||||
ErrorSnapshot = DocType("Error Snapshot") | |||||
frappe.db.delete(ErrorSnapshot, filters=( | |||||
ErrorSnapshot.creation < (Now() - Interval(months=1)) | |||||
)) | |||||
path = get_error_snapshot_path() | path = get_error_snapshot_path() | ||||
today = datetime.datetime.now() | today = datetime.datetime.now() | ||||
@@ -34,7 +34,7 @@ def after_install(): | |||||
print_settings.save() | print_settings.save() | ||||
# all roles to admin | # all roles to admin | ||||
frappe.get_doc("User", "Administrator").add_roles(*frappe.db.sql_list("""select name from tabRole""")) | |||||
frappe.get_doc("User", "Administrator").add_roles(*frappe.get_all("Role", pluck="name")) | |||||
# update admin password | # update admin password | ||||
update_password("Administrator", get_admin_password()) | update_password("Administrator", get_admin_password()) | ||||
@@ -64,14 +64,14 @@ class UserPermissions: | |||||
def build_doctype_map(self): | def build_doctype_map(self): | ||||
"""build map of special doctype properties""" | """build map of special doctype properties""" | ||||
self.doctype_map = {} | |||||
active_domains = frappe.get_active_domains() | active_domains = frappe.get_active_domains() | ||||
all_doctypes = frappe.get_all("DocType", fields=["name", "in_create", "module", "istable", "issingle", "read_only", "restrict_to_domain"]) | |||||
self.doctype_map = {} | |||||
for r in frappe.db.sql("""select name, in_create, issingle, istable, | |||||
read_only, restrict_to_domain, module from tabDocType""", as_dict=1): | |||||
if (not r.restrict_to_domain) or (r.restrict_to_domain in active_domains): | |||||
self.doctype_map[r['name']] = r | |||||
for dt in all_doctypes: | |||||
if not dt.restrict_to_domain or (dt.restrict_to_domain in active_domains): | |||||
self.doctype_map[dt["name"]] = dt | |||||
def build_perm_map(self): | def build_perm_map(self): | ||||
"""build map of permissions at level 0""" | """build map of permissions at level 0""" | ||||