fix(file): attached_to_name can be an integer (#18909)
* fix(file): attached_to_name can be an integer incorrect validation introduces via https://github.com/frappe/frappe/pull/18880 * test(file): set correct fieldname * fix: check for str, int explicitly
This commit is contained in:
parent
f3c00c2bdc
commit
edf01ee1cd
2 changed files with 3 additions and 3 deletions
|
|
@ -101,8 +101,8 @@ class File(Document):
|
|||
if not self.attached_to_doctype:
|
||||
return
|
||||
|
||||
if self.attached_to_name and not isinstance(self.attached_to_name, str):
|
||||
frappe.throw(_("Attached To Name must be a string"), TypeError)
|
||||
if not self.attached_to_name or not isinstance(self.attached_to_name, (str, int)):
|
||||
frappe.throw(_("Attached To Name must be a string or an integer"), frappe.ValidationError)
|
||||
|
||||
if not self.attached_to_field:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class TestBase64File(FrappeTestCase):
|
|||
"doctype": "File",
|
||||
"file_name": "test_base64.txt",
|
||||
"attached_to_doctype": self.attached_to_doctype,
|
||||
"attached_to_docname": self.attached_to_docname,
|
||||
"attached_to_name": self.attached_to_docname,
|
||||
"content": self.test_content,
|
||||
"decode": True,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue