Skip to content

Commit

Permalink
fix: Convert doctype name to string (#19832) (#19834)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1eab4e4)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed Jan 30, 2023
1 parent 3e91fb1 commit a45f31d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions frappe/core/doctype/docshare/test_docshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,17 @@ def test_share_with_submit_perm(self):
)

frappe.share.remove(doctype, submittable_doc.name, self.user)

def test_share_int_pk(self):
test_doc = frappe.new_doc("Console Log")

test_doc.insert()
frappe.share.add("Console Log", test_doc.name, self.user)

frappe.set_user(self.user)
self.assertIn(
str(test_doc.name), [str(name) for name in frappe.get_list("Console Log", pluck="name")]
)

test_doc.reload()
self.assertTrue(test_doc.has_permission("read"))
2 changes: 1 addition & 1 deletion frappe/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def get_linked_doctypes(dt: str) -> list:
def get_doc_name(doc):
if not doc:
return None
return doc if isinstance(doc, str) else doc.name
return doc if isinstance(doc, str) else str(doc.name)


def allow_everything():
Expand Down

0 comments on commit a45f31d

Please sign in to comment.