[fix] Ignore duplicate entry error for file data

This commit is contained in:
Anand Doshi 2014-07-29 16:19:42 +05:30
parent a17ead57be
commit 89fa91bd4e
3 changed files with 14 additions and 14 deletions

View file

@ -18,17 +18,18 @@ class FileData(Document):
frappe.local.rollback_observers.append(self)
def on_update(self):
# check duplicate assignement
n_records = frappe.db.sql("""select name from `tabFile Data`
where content_hash=%s
and name!=%s
and attached_to_doctype=%s
and attached_to_name=%s""", (self.content_hash, self.name, self.attached_to_doctype,
self.attached_to_name))
if len(n_records) > 0:
self.duplicate_entry = n_records[0][0]
frappe.msgprint(frappe._("Same file has already been attached to the record"))
raise frappe.DuplicateEntryError
if not getattr(self, "ignore_duplicate_entry_error", False):
# check duplicate assignement
n_records = frappe.db.sql("""select name from `tabFile Data`
where content_hash=%s
and name!=%s
and attached_to_doctype=%s
and attached_to_name=%s""", (self.content_hash, self.name, self.attached_to_doctype,
self.attached_to_name))
if len(n_records) > 0:
self.duplicate_entry = n_records[0][0]
frappe.msgprint(frappe._("Same file has already been attached to the record"))
raise frappe.DuplicateEntryError
def on_trash(self):
if self.attached_to_name:

View file

@ -71,7 +71,7 @@
"label": "Print Format Type",
"options": "Server\nClient",
"permlevel": 0,
"read_only": 1
"read_only": 0
},
{
"fieldname": "disabled",
@ -119,7 +119,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2014-07-22 03:22:47.308355",
"modified": "2014-07-29 06:40:58.557378",
"modified_by": "Administrator",
"module": "Core",
"name": "Print Format",

View file

@ -1,4 +1,3 @@
{%- set section_made = False -%}
{%- from "templates/print_formats/standard_macros.html" import add_header,
render_field -%}