From 3e15a03a91dbb908d0655d55177980feba4848f9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 22 Jul 2011 17:06:40 +0530 Subject: [PATCH] doctype.py: added get_property and called in tags --- cgi-bin/webnotes/model/doctype.py | 16 +++++++++++++--- cgi-bin/webnotes/widgets/tags.py | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cgi-bin/webnotes/model/doctype.py b/cgi-bin/webnotes/model/doctype.py index 1090eddef8..15a77c016a 100644 --- a/cgi-bin/webnotes/model/doctype.py +++ b/cgi-bin/webnotes/model/doctype.py @@ -273,9 +273,19 @@ class _DocType: def clear_cache(): webnotes.conn.sql("delete from __DocTypeCache") -# Load "DocType" - called by form builder, report buider and from code.py (when there is no cache) -#================================================================================================= - +def get_property(dt, property): + """ + get a doctype property, override it from property setter if specified + """ + prop = webnotes.conn.sql(""" + select value + from `tabProperty Setter` + where doc_type=%s and doc_name=%s and property=%s""", (dt, dt, property), as_dict=1): + if prop: + return prop[0][0] + else: + return webnotes.conn.get_value('DocType', dt, property) + 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/widgets/tags.py b/cgi-bin/webnotes/widgets/tags.py index b08429e8e8..b2ac4e236c 100644 --- a/cgi-bin/webnotes/widgets/tags.py +++ b/cgi-bin/webnotes/widgets/tags.py @@ -205,7 +205,9 @@ class TagCounter: def get_top_field_tags(dt): - tf = webnotes.conn.get_value('DocType', dt, 'tag_fields') + from webnotes.model.doctype import get_property + tf = get_property(dt, 'tag_fields') + if not tf: return [] # restrict to only 2 fields