Skip to content

Commit

Permalink
Merge pull request frappe#28595 from akhilnarang/check-permission-bef…
Browse files Browse the repository at this point in the history
…ore-merge

fix(rename): check for permissions for merged document as well
  • Loading branch information
akhilnarang authored Nov 28, 2024
2 parents 0dcc628 + a70973b commit 49fe842
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions frappe/model/rename_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,15 @@ def validate_rename(

kwargs = {"doctype": doctype, "ptype": "write", "print_logs": False}
if old_doc:
kwargs |= {"doc": old_doc}
kwargs["doc"] = old_doc

if not (ignore_permissions or frappe.permissions.has_permission(**kwargs)):
frappe.throw(_("You need write permission to rename"))
frappe.throw(_("You need write permission on {0} {1} to rename").format(doctype, old))

if merge:
kwargs["doc"] = frappe.get_doc(doctype, new)
if not (ignore_permissions or frappe.permissions.has_permission(**kwargs)):
frappe.throw(_("You need write permission on {0} {1} to merge").format(doctype, new))

if not force and not ignore_permissions and not meta.allow_rename:
frappe.throw(_("{0} not allowed to be renamed").format(_(doctype)))
Expand Down

0 comments on commit 49fe842

Please sign in to comment.