show child table values in doclistview

This commit is contained in:
Anand Doshi 2012-06-29 18:08:55 +05:30
parent 591456df4f
commit 3ac7bf6430

View file

@ -58,12 +58,19 @@ def get(arg=None):
if not data.get('order_by'):
data['order_by'] = tables[0] + '.modified desc'
if len(tables) > 1:
data['group_by'] = "group by " + tables[0] + ".name"
else:
data['group_by'] = ''
check_sort_by_table(data.get('order_by'), tables)
add_limit(data)
query = """select %(fields)s from %(tables)s where %(conditions)s
order by %(order_by)s %(limit)s""" % data
%(group_by)s order by %(order_by)s %(limit)s""" % data
return webnotes.conn.sql(query, as_dict=1)
def check_sort_by_table(sort_by, tables):
@ -132,7 +139,7 @@ def build_conditions(filters):
# match conditions
build_match_conditions(data, conditions)
return conditions
def build_filter_conditions(data, filters, conditions):
@ -175,6 +182,8 @@ def get_tables():
# add tables from fields
for f in json.loads(data['fields']):
table_name = f.split('.')[0]
if table_name.lower().startswith('group_concat('):
table_name = table_name[13:]
# check if ifnull function is used
if table_name.lower().startswith('ifnull('):
table_name = table_name[7:]