From bbaa1df757ca128e5daf3fc4c8d8374bd273965d Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Jul 2013 11:17:43 +0530 Subject: [PATCH 1/3] [fix] Update in get_values (ignore) condition to allow tags --- webnotes/db.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webnotes/db.py b/webnotes/db.py index 235fe669a0..536c7e2a36 100644 --- a/webnotes/db.py +++ b/webnotes/db.py @@ -323,10 +323,10 @@ class Database: try: return self.get_values_from_table(fields, filters, doctype, as_dict, debug) except Exception, e: - if e.args[0]!=1146: + if ignore and e.args[0] in (1146, 1054): + return None + else: raise e - - # not a table, try in singles return self.get_values_from_single(fields, filters, doctype, as_dict, debug) From 01baf2712c7d9bed9847fd7f9e7002c29949bb89 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Jul 2013 14:03:08 +0530 Subject: [PATCH 2/3] [fixes] ignore single doctypes in chekcing linked documents --- webnotes/model/utils.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/webnotes/model/utils.py b/webnotes/model/utils.py index bc33881fc2..264e6ba0db 100644 --- a/webnotes/model/utils.py +++ b/webnotes/model/utils.py @@ -212,18 +212,19 @@ def check_if_doc_is_linked(dt, dn, method="Delete"): """ from webnotes.model.rename_doc import get_link_fields link_fields = get_link_fields(dt) - link_fields = [[lf['parent'], lf['fieldname']] for lf in link_fields] + link_fields = [[lf['parent'], lf['fieldname'], lf['issingle']] for lf in link_fields] - for link_dt, link_field in link_fields: - item = webnotes.conn.get_value(link_dt, {link_field:dn}, ["name", "parent", "parenttype", - "docstatus"], as_dict=True) + for link_dt, link_field, issingle in link_fields: + if not issingle: + item = webnotes.conn.get_value(link_dt, {link_field:dn}, + ["name", "parent", "parenttype", "docstatus"], as_dict=True) - if item and item.parent != dn and (method=="Delete" or - (method=="Cancel" and item.docstatus==1)): - webnotes.msgprint(method + " " + _("Error") + ":"+\ - ("%s (%s) " % (dn, dt)) + _("is linked in") + (" %s (%s)") % - (item.parent or item.name, item.parent and item.parenttype or link_dt), - raise_exception=LinkExistsError) + if item and item.parent != dn and (method=="Delete" or + (method=="Cancel" and item.docstatus==1)): + webnotes.msgprint(method + " " + _("Error") + ":"+\ + ("%s (%s) " % (dn, dt)) + _("is linked in") + (" %s (%s)") % + (item.parent or item.name, item.parent and item.parenttype or link_dt), + raise_exception=LinkExistsError) def round_floats_in_doc(doc, precision_map): from webnotes.utils import flt From 9b954300f9eaaafe2ede9a4a4e3dd87ec46f6931 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 2 Jul 2013 11:22:46 +0530 Subject: [PATCH 3/3] [db.py] get_values will look in Singles if table not found. --- webnotes/db.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webnotes/db.py b/webnotes/db.py index 536c7e2a36..903368ffd1 100644 --- a/webnotes/db.py +++ b/webnotes/db.py @@ -324,7 +324,11 @@ class Database: return self.get_values_from_table(fields, filters, doctype, as_dict, debug) except Exception, e: if ignore and e.args[0] in (1146, 1054): + # table or column not found, return None return None + elif (not ignore) and e.args[0]==1146: + # table not found, look in singles + pass else: raise e