Merge branch 'master' into dev
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index a9bbcb1..335d47c 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -169,6 +169,13 @@
 		get_obj('Account', self.doc.parent_account).update_balance(fy, period_det, flag)
 		msgprint('Balances updated')
 	
+	def validate_mandatory(self):
+		if not self.doc.debit_or_credit:
+			msgprint("Debit or Credit field is mandatory", raise_exception=1)
+		if not self.doc.is_pl_account:
+			msgprint("Is PL Account field is mandatory", raise_exception=1)
+
+
 	# VALIDATE
 	# ==================================================================
 	def validate(self): 
@@ -177,6 +184,7 @@
 		self.validate_parent()
 		self.validate_duplicate_account()
 		self.validate_root_details()
+		self.validate_mandatory()
 	
 		# Defaults
 		if not self.doc.parent_account:
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
index 5c13096..7dd09c5 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js
@@ -179,11 +179,7 @@
 
 /****************** Get Accounting Entry *****************/
 cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){
-	var callback = function(report){
-		report.set_filter('GL Entry', 'Voucher No',doc.name);
-		report.dt.run();
-	}
-	loadreport('GL Entry','General Ledger', callback);
+	wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);	
 }
 
 
diff --git a/erpnext/accounts/doctype/purchase_invoice/listview.js b/erpnext/accounts/doctype/purchase_invoice/listview.js
index 54913a5..c0c6625 100644
--- a/erpnext/accounts/doctype/purchase_invoice/listview.js
+++ b/erpnext/accounts/doctype/purchase_invoice/listview.js
@@ -4,6 +4,7 @@
 		this._super(d);
 		this.fields = this.fields.concat([
 			'`tabPurchase Invoice`.supplier_name',
+			'`tabPurchase Invoice`.credit_to',
 			'`tabPurchase Invoice`.currency',
 			'IFNULL(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import',
 			'IFNULL(`tabPurchase Invoice`.grand_total, 0) as grand_total',
@@ -24,7 +25,13 @@
 		{width: '5%', content: 'avatar'},
 		{width: '3%', content: 'docstatus'},
 		{width: '15%', content: 'name'},
-		{width: '34%', content: 'supplier_name+tags', css: {color: '#222'}},
+		{
+			width: '34%', 
+			content: function(parent, data) {
+				$(parent).html(data.supplier_name?data.supplier_name:data.credit_to)
+			}, 
+			css: {color: '#222'}
+		},
 		{
 			width: '18%', 
 			content: function(parent, data) { 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 3f33398..c9b4720 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -397,9 +397,5 @@
 
 /****************** Get Accounting Entry *****************/
 cur_frm.cscript.view_ledger_entry = function(){
-	var callback = function(report){
-		report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
-		report.dt.run();
-	}
-	loadreport('GL Entry','General Ledger', callback);
+	wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);
 }
diff --git a/erpnext/accounts/doctype/sales_invoice/listview.js b/erpnext/accounts/doctype/sales_invoice/listview.js
index 8171b91..ae923f4 100644
--- a/erpnext/accounts/doctype/sales_invoice/listview.js
+++ b/erpnext/accounts/doctype/sales_invoice/listview.js
@@ -4,6 +4,7 @@
 		this._super(d);
 		this.fields = this.fields.concat([
 			"`tabSales Invoice`.customer_name", 
+			"`tabSales Invoice`.debit_to", 
 			"ifnull(`tabSales Invoice`.outstanding_amount,0) as outstanding_amount", 
 			"ifnull(`tabSales Invoice`.grand_total,0) as grand_total", 
 			"`tabSales Invoice`.currency", 
@@ -19,7 +20,13 @@
 		{width: '5%', content: 'avatar'},
 		{width: '3%', content: 'docstatus'},
 		{width: '15%', content: 'name'},
-		{width: '34%', content: 'customer_name+tags', css: {color:'#222'}},
+		{
+			width: '34%', 
+			content: function(parent, data) {
+				$(parent).html(data.customer_name?data.customer_name:data.debit_to)
+			}, 
+			css: {color: '#222'}
+		},
 		{
 			width: '18%', 
 			content: function(parent, data) { 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 2badf4d..c69c5f8 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -494,12 +494,8 @@
 
 
 /****************** Get Accounting Entry *****************/
-cur_frm.cscript.view_ledger_entry = function(){
-	var callback = function(report){
-		report.set_filter('GL Entry', 'Voucher No',cur_frm.doc.name);
-		report.dt.run();
-	}
-	loadreport('GL Entry','General Ledger', callback);
+cur_frm.cscript.view_ledger_entry = function(){	
+	wn.set_route('Report', 'GL Entry', 'General Ledger', 'Voucher No='+cur_frm.doc.name);
 }
 
 // Default values for recurring invoices
diff --git a/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.py b/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.py
index e46d548..d08599f 100644
--- a/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.py
+++ b/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.py
@@ -18,8 +18,8 @@
 # -----------
 row_list = [['Cost Center','Data','160px'],
             ['Account','Data','160px'],
-            ['Debit','Data','120px'],
-            ['Credit','Data','120px'], 
+            ['Debit','Currency','120px'],
+            ['Credit','Currency','120px'], 
             ['Expense','Currency','120px']]  
 
 for r in row_list:
diff --git a/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.sql b/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.sql
index 5b22add..b5fbb7c 100644
--- a/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.sql
+++ b/erpnext/accounts/search_criteria/cost_center_wise_expense/cost_center_wise_expense.sql
@@ -1,12 +1,20 @@
-SELECT `tabGL Entry`.`cost_center`,`tabAccount`.`parent_account`,sum(`tabGL Entry`.`debit`),sum(`tabGL Entry`.`credit`),sum(`tabGL Entry`.`debit`)-sum(`tabGL Entry`.`credit`) 
- FROM `tabGL Entry`,`tabAccount`
- WHERE `tabGL Entry`.`account`=`tabAccount`.`name`
- AND ifnull(`tabGL Entry`.`is_cancelled`,'No')='No'
- AND `tabAccount`.is_pl_account='Yes'
- AND `tabAccount`.debit_or_credit='Debit' 
- AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
- AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
- AND `tabGL Entry`.`company` LIKE '%(company)s%%' 
- AND `tabAccount`.`parent_account` LIKE '%(account)s%%'
- AND `tabGL Entry`.`cost_center` LIKE '%(cost_center)s%%' 
- GROUP BY `tabGL Entry`.`cost_center` , `tabAccount`.`parent_account`
\ No newline at end of file
+SELECT 
+	`tabGL Entry`.`cost_center`,
+	`tabAccount`.`parent_account`, 
+	sum(ifnull(`tabGL Entry`.`debit`, 0)), 
+	sum(ifnull(`tabGL Entry`.`credit`, 0)), 
+	sum(ifnull(`tabGL Entry`.`debit`,0))-sum(ifnull(`tabGL Entry`.`credit`, 0)) 
+ FROM 
+	`tabGL Entry`,`tabAccount`
+ WHERE 
+	`tabGL Entry`.`account`=`tabAccount`.`name`
+	 AND ifnull(`tabGL Entry`.`is_cancelled`,'No')='No'
+	 AND `tabAccount`.is_pl_account='Yes'
+	 AND `tabAccount`.debit_or_credit='Debit' 
+	 AND `tabGL Entry`.`posting_date`>='%(posting_date)s'
+	 AND `tabGL Entry`.`posting_date`<='%(posting_date1)s'
+	 AND `tabGL Entry`.`company` LIKE '%(company)s%%' 
+	 AND `tabAccount`.`parent_account` LIKE '%(account)s%%'
+	 AND `tabGL Entry`.`cost_center` LIKE '%(cost_center)s%%' 
+ GROUP BY 
+	`tabGL Entry`.`cost_center` , `tabAccount`.`parent_account`
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index 67a2aae..20de364 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -163,10 +163,21 @@
 			delete from `tabCommunication`
 			where supplier = %s and customer is null""", self.doc.name)
 			
+	def delete_supplier_account(self):
+		"""delete supplier's ledger if exist and check balance before deletion"""
+		acc = sql("select name from `tabAccount` where master_type = 'Supplier' \
+			and master_name = %s and docstatus < 2", self.doc.name)
+		if acc:
+			from webnotes.model import delete_doc
+			delete_doc('Account', acc[0][0])
+			
+			
 	def on_trash(self):
 		self.delete_supplier_address()
 		self.delete_supplier_contact()
 		self.delete_supplier_communication()
+		self.delete_supplier_account()
+		
 		
 	# on rename
 	# ---------
diff --git a/erpnext/patches/june_2012/alter_tabsessions.py b/erpnext/patches/june_2012/alter_tabsessions.py
new file mode 100644
index 0000000..1ea4d7c
--- /dev/null
+++ b/erpnext/patches/june_2012/alter_tabsessions.py
@@ -0,0 +1,5 @@
+def execute():
+	import webnotes
+	webnotes.conn.commit()
+	webnotes.conn.sql("alter table `tabSessions` modify user varchar(180)")
+	webnotes.conn.begin()
\ No newline at end of file
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index fd734a9..03c0f27 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -447,4 +447,9 @@
 		'patch_file': 'set_recurring_type',
 		'description': "set recurring type as monthly in old"
 	},
+	{
+		'patch_module': 'patches.june_2012',
+		'patch_file': 'alter_tabsessions',
+		'description': "alter tabsessions to change user column definition"
+	},
 ]
\ No newline at end of file
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index bdc6487..0dd3635 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -239,12 +239,20 @@
 		webnotes.conn.sql("""\
 			delete from `tabCommunication`
 			where customer = %s and supplier is null""", self.doc.name)
-	
-# ******************************************************* on trash *********************************************************
+			
+	def delete_customer_account(self):
+		"""delete customer's ledger if exist and check balance before deletion"""
+		acc = sql("select name from `tabAccount` where master_type = 'Customer' \
+			and master_name = %s and docstatus < 2", self.doc.name)
+		if acc:
+			from webnotes.model import delete_doc
+			delete_doc('Account', acc[0][0])
+
 	def on_trash(self):
 		self.delete_customer_address()
 		self.delete_customer_contact()
 		self.delete_customer_communication()
+		self.delete_customer_account()
 		if self.doc.lead_name:
 			sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
 			
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 4be65ae..ce5f9dd 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -160,13 +160,9 @@
 	var cond = '';
 	
 	if(doc.customer) {
-		if(doc.currency) cond = '`tabSales Order`.customer = "'+doc.customer+'" and `tabSales Order`.currency = "'+doc.currency+'" and';
-		else cond = '`tabSales Order`.customer = "'+doc.customer+'" and';
+		cond = '`tabSales Order`.customer = "'+doc.customer+'" and';
 	}
-	else {
-		if(doc.currency) cond = '`tabSales Order`.currency = "'+doc.currency+'" and';
-		else cond = '';
-	}
+
 	if(doc.project_name){
 		cond += '`tabSales Order`.project_name ="'+doc.project_name+'"';
 	}
diff --git a/public/js/all-app.js b/public/js/all-app.js
index 1e4fead..384f8f9 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -1033,15 +1033,16 @@
  *	lib/js/wn/views/reportview.js
  */
 wn.views.reportview={show:function(dt,rep_name){wn.require('js/report-legacy.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
-_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t)){rb.dt.run();}}
+_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;var route_changed=(rb.current_route!=wn.get_route_str())
+rb.load_criteria(rep_name);if(rb.dt&&route_changed){rb.dt.run();}}
 if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
 wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportViewPage(route[1],route[2]);}else{wn.set_route('404');}}}}
 wn.views.ReportViewPage=Class.extend({init:function(doctype,docname){this.doctype=doctype;this.docname=docname;this.page_name=wn.get_route_str();this.make_page();var me=this;wn.model.with_doctype(doctype,function(){me.make_report_view();if(docname){wn.model.with_doc('Report',docname,function(r){me.reportview.set_columns_and_filters(JSON.parse(locals['Report'][docname].json));me.reportview.run();});}else{me.reportview.run();}});},make_page:function(){this.page=wn.container.add_page(this.page_name);wn.ui.make_app_page({parent:this.page,single_column:true});wn.container.change_to(this.page_name);},make_report_view:function(){wn.views.breadcrumbs($('<span>').appendTo(this.page.appframe.$titlebar),locals.DocType[this.doctype].module);this.reportview=new wn.views.ReportView(this.doctype,this.docname,this.page)}})
-wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname,page){var me=this;$(page).find('.layout-main').html('Loading Report...');this.import_slickgrid();$(page).find('.layout-main').empty();this.doctype=doctype;this.docname=docname;this.page=page;this.tab_name='`tab'+doctype+'`';this.setup();},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'&&df.fieldtype!='Table'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_full_column_name([this.sort_by_select.val()])
+wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname,page){var me=this;$(page).find('.layout-main').html('Loading Report...');this.import_slickgrid();$(page).find('.layout-main').empty();this.doctype=doctype;this.docname=docname;this.page=page;this.tab_name='`tab'+doctype+'`';this.setup();},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'&&df.fieldtype!='Table'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_selected_table_and_column(this.sort_by_select)
 +' '+this.sort_order_select.val()
-if(this.sort_by_next_select.val()){order_by+=', '+this.get_full_column_name([this.sort_by_next_select.val()])
+if(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_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){var docfield=wn.meta.docfield_map[c[1]||me.doctype][c[0]];coldef={id:c[0],field:c[0],docfield:docfield,name:(docfield?docfield.label:toTitle(c[0])),width:(docfield?cint(docfield.width):120)||120}
+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_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){var docfield=wn.meta.docfield_map[c[1]||me.doctype][c[0]];coldef={id:c[0],field:c[0],docfield:docfield,name:(docfield?docfield.label:toTitle(c[0])),width:(docfield?cint(docfield.width):120)||120}
 if(c[0]=='name'){coldef.formatter=function(row,cell,value,columnDef,dataContext){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:me.doctype,name:value});}}else if(docfield&&docfield.fieldtype=='Link'){coldef.formatter=function(row,cell,value,columnDef,dataContext){if(value){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:columnDef.docfield.options,name:value});}else{return'';}}}
 return coldef;});},render_list:function(){var me=this;var columns=[{id:'_idx',field:'_idx',name:'Sr.',width:40}].concat(this.build_columns());$.each(this.data,function(i,v){v._idx=i+1;});var options={enableCellNavigation:true,enableColumnReorder:false};var grid=new Slick.Grid(this.$w.find('.result-list').css('border','1px solid grey').css('height','500px').get(0),this.data,columns,options);},make_column_picker:function(){var me=this;this.column_picker=new wn.ui.ColumnPicker(this);this.page.appframe.add_button('Pick Columns',function(){me.column_picker.show(me.columns);},'icon-th-list');},make_sorter:function(){var me=this;this.sort_dialog=new wn.ui.Dialog({title:'Sorting Preferences'});$(this.sort_dialog.body).html('<p class="help">Sort By</p>\
    <div class="sort-column"></div>\
diff --git a/public/js/report-legacy.js b/public/js/report-legacy.js
index 6f7fae6..0d757b6 100644
--- a/public/js/report-legacy.js
+++ b/public/js/report-legacy.js
@@ -51,7 +51,7 @@
 me.make_datatable();me.orig_sort_list=[];if(me.parent_dt){me.setup_dt_filters_and_cols(fl,me.parent_dt);var fl=[];}
 me.setup_dt_filters_and_cols(fl,me.doctype);if(!this.has_primary_filters)
 $dh(this.report_filters.first_page_filter);this.column_picker.refresh();$ds(me.body);}
-_r.ReportBuilder.prototype.set_filters_from_route=function(){var route=wn.get_route();if(route.length>3){for(var i=3;i<route.length;i++){var p=route[i].split('=');if(p.length==2){var dt=this.parent_dt?this.parent_dt:this.doctype;this.set_filter(dt,p[0],p[1]);}}}}
+_r.ReportBuilder.prototype.set_filters_from_route=function(){var route=wn.get_route();this.current_route=wn.get_route_str();if(route.length>3){for(var i=3;i<route.length;i++){var p=route[i].split('=');if(p.length==2){var dt=this.parent_dt?this.parent_dt:this.doctype;this.set_filter(dt,p[0],p[1]);}}}}
 _r.ReportBuilder.prototype.add_filter=function(f){if(this.filter_fields_dict[f.parent+'\1'+f.label]){this.filter_fields_dict[f.parent+'\1'+f.label].df=f;}else{this.report_filters.add_field(f,f.parent,null,1);}}
 _r.ReportBuilder.prototype.setup_dt_filters_and_cols=function(fl,dt){var me=this;var lab=$a(me.filter_area,'div','filter_dt_head');lab.innerHTML='Filters for '+get_doctype_label(dt);var lab=$a(me.picker_area,'div','builder_dt_head');lab.innerHTML='Select columns for '+get_doctype_label(dt);var dt_fields=wn.meta.docfield_list[dt];for(var i=0;i<dt_fields.length;i++){fl[fl.length]=dt_fields[i];}
 var sf_list=locals.DocType[dt].search_fields?locals.DocType[dt].search_fields.split(','):[];for(var i in sf_list)sf_list[i]=strip(sf_list[i]);for(var i=0;i<fl.length;i++){var f=fl[i];if(f&&cint(f.in_filter)){me.report_filters.add_field(f,dt,in_list(sf_list,f.fieldname));}