From 8b14617dce2ee416d19bddf1ed92e1b0d861fd8f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 25 Jun 2012 13:15:59 +0530 Subject: [PATCH] run view ledger report through set_route --- .../accounts/doctype/journal_voucher/journal_voucher.js | 6 +----- .../accounts/doctype/purchase_invoice/purchase_invoice.js | 6 +----- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 8 ++------ public/js/all-app.js | 3 ++- public/js/report-legacy.js | 2 +- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index 5c13096aa4f..7dd09c5e623 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -179,11 +179,7 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ /****************** 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/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 3f333983b06..c9b4720c3cb 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -397,9 +397,5 @@ cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ /****************** 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/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 2badf4d6be0..c69c5f8b807 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -494,12 +494,8 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) { /****************** 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/public/js/all-app.js b/public/js/all-app.js index c9cd80c8544..dbdc42f0053 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1032,7 +1032,8 @@ wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});}) * 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($('').appendTo(this.page.appframe.$titlebar),locals.DocType[this.doctype].module);this.reportview=new wn.views.ReportView(this.doctype,this.docname,this.page)}}) diff --git a/public/js/report-legacy.js b/public/js/report-legacy.js index 6f7fae671d1..0d757b629c3 100644 --- a/public/js/report-legacy.js +++ b/public/js/report-legacy.js @@ -51,7 +51,7 @@ var me=this;var dt=me.parent_dt?me.parent_dt:me.doctype;var fl=[{'fieldtype':'Da 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;i3){for(var i=3;i