hi have a html form with 3 attachment field
when i attach files my_file_1.txt, my_file_2.txt ,my_file_3.txt in 3 attachment attachment respectivly. I am getting
Same file has already been attached to the record. to avoid that i wrote below code in validate_duplicate_entry function of files.py doctype
n_records = frappe.db.sql(""“select name from
and attached_to_name=%s”"", (self.content_hash, self.name, self.attached_to_doctype,
if len(n_records) > 0:
self.duplicate_entry = n_records
if self.attached_to_doctype != “MyDoctype”:
frappe.throw(frappe._(“Same file has already been attached to the record”), frappe.DuplicateEntryError)
what the code i added is this
if self.attached_to_doctype != "Student Applicant":
but when i submit the html form 3 attachments with same name on my doctype
oh i forget to mention that when this html form is submits data will be saved to
so i think that frappe i automatically detecting content of the file or something like that how can i buy pass that.
version of erpnext that i use is 7
i assume that you already fixed in v 10. but my curiosity to find how frappe identifying the content of file or similarity of file name forced me to put this question in here.
if any one who had already done some thing like this before pls share.
code for saving file is
filedoc = save_file(fd[“filename”], fd[“dataurl”],
“Student Applicant”, tRF.name, decode=False, is_private=1)