fix: check permission on new doc (#31626)

User might only have "only if creator" permission so checking on doctype
will incorrectly flag it.

Not sure if there's any better/simpler way to handle this. This is weird
edge case on how files operate.
This commit is contained in:
Ankush Menat 2025-03-10 19:00:13 +05:30 committed by GitHub
parent 4f823f5a10
commit 8d15d28463
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -217,7 +217,7 @@ def check_write_permission(doctype: str | None = None, name: str | None = None):
except frappe.DoesNotExistError:
# doc has not been inserted yet, name is set to "new-some-doctype"
# If doc inserts fine then only this attachment will be linked see file/utils.py:relink_mismatched_files
check_doctype_permission(doctype, "write")
frappe.new_doc(doctype).check_permission("write")
return
doc.check_permission("write")