From 6f6fe9a00642aa0d6de62f61eb23ddd5f14423a9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 26 Jul 2011 18:11:12 +0530 Subject: [PATCH 1/4] fixed spelling mistake in search_criteria.py --- cgi-bin/core/doctype/search_criteria/search_criteria.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cgi-bin/core/doctype/search_criteria/search_criteria.py b/cgi-bin/core/doctype/search_criteria/search_criteria.py index 00e5eb4330..15cfa703c7 100644 --- a/cgi-bin/core/doctype/search_criteria/search_criteria.py +++ b/cgi-bin/core/doctype/search_criteria/search_criteria.py @@ -28,7 +28,7 @@ class DocType: def validate(self): if sql("select name from `tabSearch Criteria` where criteria_name=%s and name!=%s", (self.doc.criteria_name, self.doc.name)): - webnots.msgprint("Criteria Name '%s' already used, please use another name" % self.doc.criteria_name, raise_exception = 1) + webnotes.msgprint("Criteria Name '%s' already used, please use another name" % self.doc.criteria_name, raise_exception = 1) def on_update(self): self.set_module() @@ -72,4 +72,4 @@ class DocType: if os.path.exists(os.path.join(path, old_name + extn)): os.system('cp %s %s' % (os.path.join(path, old_name + extn), \ os.path.join(get_module_path(self.doc.module), 'search_criteria', scrub(self.doc.name), scrub(self.doc.name) + extn))) - \ No newline at end of file + From 182111306c6253104299e485d88ac47b7f21d467 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Aug 2011 11:32:28 +0530 Subject: [PATCH 2/4] checked if duplicate lft, rgt exists in nested set model --- cgi-bin/webnotes/utils/nestedset.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/utils/nestedset.py b/cgi-bin/webnotes/utils/nestedset.py index 13af8ec4de..ffeaf7abde 100644 --- a/cgi-bin/webnotes/utils/nestedset.py +++ b/cgi-bin/webnotes/utils/nestedset.py @@ -65,7 +65,11 @@ def update_add_node(doctype, name, parent, parent_field): webnotes.conn.sql("update `tab%s` set rgt = rgt+2 where rgt >= %s" %(doctype,right)) webnotes.conn.sql("update `tab%s` set lft = lft+2 where lft >= %s" %(doctype,right)) - #$ update index of new node + # update index of new node + if webnotes.conn.sql("select * from `tab%s` where lft=%s or rgt=%s"% (doctype, right, right+1)) + webnotes.msgprint("Nested set error. Please send mail to support") + raise Exception + webnotes.conn.sql("update `tab%s` set lft=%s, rgt=%s where name='%s'" % (doctype,right,right+1,name)) return right From 356998c1ff3bf8fa0cd353c1980be2ed49971b3e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 3 Aug 2011 11:55:42 +0530 Subject: [PATCH 3/4] checked if duplicate lft, rgt exists in nested set model --- cgi-bin/webnotes/utils/nestedset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/utils/nestedset.py b/cgi-bin/webnotes/utils/nestedset.py index ffeaf7abde..97cf156074 100644 --- a/cgi-bin/webnotes/utils/nestedset.py +++ b/cgi-bin/webnotes/utils/nestedset.py @@ -66,7 +66,7 @@ def update_add_node(doctype, name, parent, parent_field): webnotes.conn.sql("update `tab%s` set lft = lft+2 where lft >= %s" %(doctype,right)) # update index of new node - if webnotes.conn.sql("select * from `tab%s` where lft=%s or rgt=%s"% (doctype, right, right+1)) + if webnotes.conn.sql("select * from `tab%s` where lft=%s or rgt=%s"% (doctype, right, right+1)): webnotes.msgprint("Nested set error. Please send mail to support") raise Exception From 68b1fe780b6e56f41d91e23d24d20d2adca4d8ed Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 4 Aug 2011 10:39:38 +0530 Subject: [PATCH 4/4] updated import to take options from property setter --- cgi-bin/webnotes/model/doctype.py | 18 ++++++++++++++++++ cgi-bin/webnotes/model/import_docs.py | 6 ++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cgi-bin/webnotes/model/doctype.py b/cgi-bin/webnotes/model/doctype.py index 6f3f3327bb..27eee1dae3 100644 --- a/cgi-bin/webnotes/model/doctype.py +++ b/cgi-bin/webnotes/model/doctype.py @@ -294,6 +294,24 @@ def get_property(dt, property): else: return webnotes.conn.get_value('DocType', dt, property) +def get_field_property(dt, fieldname, property): + """ + get a field property, override it from property setter if specified + """ + field = webnotes.conn.sql(""" + select name, `%s` + from tabDocField + where parent=%s and fieldname=%s""" % (property, '%s', '%s'), (dt, fieldname)) + + prop = webnotes.conn.sql(""" + select value + from `tabProperty Setter` + where doc_type=%s and doc_name=%s and property=%s""", (dt, field[0][0], property)) + if prop: + return prop[0][0] + else: + return field[0][1] + def get(dt): """ Load "DocType" - called by form builder, report buider and from code.py (when there is no cache) diff --git a/cgi-bin/webnotes/model/import_docs.py b/cgi-bin/webnotes/model/import_docs.py index 44c872c920..524462c35b 100644 --- a/cgi-bin/webnotes/model/import_docs.py +++ b/cgi-bin/webnotes/model/import_docs.py @@ -197,11 +197,13 @@ class CSVImport: return out def check_select_link_data(self, r, c, f, d, s = '', l = ''): + from webnotes.model.doctype import get_field_property options = '' try: if d and f: - dt = sql("select options, label from `tabDocField` where fieldname ='%s' and parent = '%s' " % (f, self.dt_list[0])) - dt, lbl = (dt and dt[0][0] and dt[0][0].strip() or None), dt and dt[0][1].strip() + dt = get_field_property(self.dt_list[0], f, 'options') + lbl = get_field_property(self.dt_list[0], f, 'label') + if dt: options = l and dt and [n[0] for n in sql("select name from `tab%s` " % (('link:' in dt and dt[5:]) or dt))] or s and dt.split('\n') or '' if options and d not in options :