Ver código fonte

Error fixed in new report: sort by child table column

version-14
Nabin Hait 13 anos atrás
pai
commit
1a079ca19c
2 arquivos alterados com 18 adições e 3 exclusões
  1. +7
    -3
      js/wn/views/reportview.js
  2. +11
    -0
      py/webnotes/widgets/doclistview.py

+ 7
- 3
js/wn/views/reportview.js Ver arquivo

@@ -192,17 +192,21 @@ wn.views.ReportView = wn.ui.Listing.extend({
get_order_by: function() {
// first
var order_by = this.get_full_column_name([this.sort_by_select.val()])
var order_by = this.get_selected_table_and_column(this.sort_by_select)
+ ' ' + this.sort_order_select.val()
// second
if(this.sort_by_next_select.val()) {
order_by += ', ' + this.get_full_column_name([this.sort_by_next_select.val()])
order_by += ', ' + this.get_selected_table_and_column(this.sort_by_next_select)
+ ' ' + this.sort_order_next_select.val()
}
return order_by;
},
get_selected_table_and_column: function($select) {
return this.get_full_column_name([$select.val(),
$select.find('option:selected').attr('table')])
},
// get table_name.column_name
get_full_column_name: function(v) {


+ 11
- 0
py/webnotes/widgets/doclistview.py Ver arquivo

@@ -55,8 +55,10 @@ def get(arg=None):
data['tables'] = ', '.join(tables)
data['conditions'] = ' and '.join(conditions)
data['fields'] = ', '.join(fields)
if not data.get('order_by'):
data['order_by'] = tables[0] + '.modified desc'
check_sort_by_table(data.get('order_by'), tables)
add_limit(data)
@@ -64,6 +66,15 @@ def get(arg=None):
order by %(order_by)s %(limit)s""" % data
return webnotes.conn.sql(query, as_dict=1)

def check_sort_by_table(sort_by, tables):
"""check atleast 1 column selected from the sort by table """
tbl = sort_by.split('.')[0]
if tbl not in tables:
if tbl.startswith('`'):
tbl = tbl[4:-1]
webnotes.msgprint("Please select atleast 1 column from '%s' to sort"\
% tbl, raise_exception=1)

def run_custom_query(data):
"""run custom query"""
query = data['query']


Carregando…
Cancelar
Salvar