From 89fa91bd4e16c7a213c6b2f730264d2ac813f4ea Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 29 Jul 2014 16:19:42 +0530 Subject: [PATCH] [fix] Ignore duplicate entry error for file data --- frappe/core/doctype/file_data/file_data.py | 23 ++++++++++--------- .../doctype/print_format/print_format.json | 4 ++-- frappe/templates/print_formats/standard.html | 1 - 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/frappe/core/doctype/file_data/file_data.py b/frappe/core/doctype/file_data/file_data.py index b54c6ff62d..ae0971d79e 100644 --- a/frappe/core/doctype/file_data/file_data.py +++ b/frappe/core/doctype/file_data/file_data.py @@ -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: diff --git a/frappe/core/doctype/print_format/print_format.json b/frappe/core/doctype/print_format/print_format.json index 23d7c533b7..b1d5f35330 100644 --- a/frappe/core/doctype/print_format/print_format.json +++ b/frappe/core/doctype/print_format/print_format.json @@ -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", diff --git a/frappe/templates/print_formats/standard.html b/frappe/templates/print_formats/standard.html index c3d9add59c..c4c97adae9 100644 --- a/frappe/templates/print_formats/standard.html +++ b/frappe/templates/print_formats/standard.html @@ -1,4 +1,3 @@ -{%- set section_made = False -%} {%- from "templates/print_formats/standard_macros.html" import add_header, render_field -%}