From 96d380b6d34c84c7596cf7b26bd14b40207c8b42 Mon Sep 17 00:00:00 2001 From: Saqib Ansari Date: Sat, 15 Nov 2025 13:26:01 +0530 Subject: [PATCH] fix: sync permission types before doctypes --- frappe/model/sync.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frappe/model/sync.py b/frappe/model/sync.py index 4feb2807d7..683947d228 100644 --- a/frappe/model/sync.py +++ b/frappe/model/sync.py @@ -15,6 +15,10 @@ from frappe.modules.patch_handler import _patch_mode from frappe.utils import update_progress_bar IMPORTABLE_DOCTYPES = [ + # for a permission type "impersonate" + # its custom field should exists in DocPerm + # to ensure permissions defined in doctype.json are synced correctly + ("core", "permission_type"), ("core", "doctype"), ("core", "page"), ("core", "report"), @@ -34,7 +38,6 @@ IMPORTABLE_DOCTYPES = [ ("core", "server_script"), ("custom", "custom_field"), ("custom", "property_setter"), - ("core", "permission_type"), ] @@ -66,10 +69,13 @@ def sync_for(app_name, force=0, reset_permissions=False): "role", "has_role", "doctype", - "permission_type", ]: files.append(os.path.join(FRAPPE_PATH, "core", "doctype", core_module, f"{core_module}.json")) + # sync permission type and its dependencies + for dt in ["user", "docshare", "custom_docperm", "docperm", "permission_type"]: + files.append(os.path.join(FRAPPE_PATH, "core", "doctype", dt, f"{dt}.json")) + for custom_module in ["custom_field", "property_setter"]: files.append( os.path.join(FRAPPE_PATH, "custom", "doctype", custom_module, f"{custom_module}.json")