fix(nestedset): clear user permissions cache when a new doc is created, if applicable
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
d5fcdff679
commit
c0c0cae78a
1 changed files with 13 additions and 0 deletions
|
|
@ -261,6 +261,19 @@ class NestedSet(Document):
|
|||
if self.meta.get("nsm_parent_field"):
|
||||
self.nsm_parent_field = self.meta.nsm_parent_field
|
||||
|
||||
def after_insert(self):
|
||||
if (
|
||||
frappe.flags.in_import
|
||||
or frappe.flags.in_patch
|
||||
or frappe.flags.in_migrate
|
||||
or frappe.flags.in_install
|
||||
):
|
||||
return
|
||||
|
||||
# Clear user permissions cache, otherwise user can't access the new document
|
||||
if frappe.db.exists("User Permission", {"user": frappe.session.user, "allow": self.doctype}):
|
||||
frappe.cache.hdel("user_permissions", frappe.session.user)
|
||||
|
||||
def on_update(self):
|
||||
update_nsm(self)
|
||||
self.validate_ledger()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue