Merge branch 'master' of git://github.com/rmehta/wnframework

This commit is contained in:
nabinhait 2011-07-01 11:12:37 +05:30
commit 178219d359
4 changed files with 20 additions and 6 deletions

View file

@ -30,7 +30,15 @@ def set_fieldname(field_id, fieldname):
#=================================================================================
def get_link_fields(doctype):
return webnotes.conn.sql("SELECT fieldname, options, label FROM tabDocField WHERE parent='%s' and (fieldtype='Link' or (fieldtype='Select' and `options` like 'link:%%'))" % (doctype))
"""
Returns list of link fields for a doctype in tuple (fieldname, options, label)
"""
return webnotes.conn.sql("""
SELECT fieldname, options, label
FROM tabDocField
WHERE parent='%s'
and (fieldtype='Link' or (fieldtype='Select' and `options` like 'link:%%'))
and fieldname!='owner'""" % (doctype))
#=================================================================================

View file

@ -168,7 +168,7 @@ def to_html(doclist):
return out
def commonify_doclist(doclist):
def commonify_doclist(doclist, with_comments=1):
"""
Makes a doclist more readable by extracting common properties.
This is used for printing Documents in files
@ -239,7 +239,7 @@ def uncommonify_doclist(dl):
final = []
for d in dl[1:]:
if d['name']=='__common__':
if 'name' in d and d['name']=='__common__':
del d['name']
common_dict[d['doctype']] = d
else:

View file

@ -69,7 +69,7 @@ def write_document_file(doclist, record_module=None):
Write a doclist to file, can optionally specify module name
"""
import os
from webnotes.utils import pprint_doclist
from webnotes.model.utils import pprint_doclist
module = get_module_name(doclist, record_module)

View file

@ -37,14 +37,20 @@ def import_module(module, verbose=0):
def get_doclist(path, doctype, docname):
"returns a doclist (list of dictionaries) of multiple records for the given parameters"
import os
from webnotes.utils import peval_doclist
from webnotes.model.utils import peval_doclist
do_not_import = ('control_panel')
fname = os.path.join(path,doctype,docname,docname+'.txt')
if os.path.exists(fname) and (doctype not in do_not_import):
f = open(fname,'r')
dl = peval_doclist(f.read())
txt = f.read()
# if exported using pprint_doclist, then file starts with a comment
if txt.startswith('#'):
dl = peval_doclist(txt)
else:
dl = eval(txt)
f.close()
return dl
else: