From c665a99a86b8ab97fde7c2837d9dd801fec353c1 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 4 Dec 2012 16:46:45 +0530 Subject: [PATCH] listview new doc bugfix --- public/js/wn/views/doclistview.js | 35 ++++++++++++++++--------------- webnotes/widgets/reportview.py | 11 ++++++---- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/public/js/wn/views/doclistview.js b/public/js/wn/views/doclistview.js index 95173200f6..30050b9dae 100644 --- a/public/js/wn/views/doclistview.js +++ b/public/js/wn/views/doclistview.js @@ -160,7 +160,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ // make_new_doc can be overridden so that default values can be prefilled // for example - communication list in customer - $(this.wrapper).find('button[list_view_doc="'+me.doctype+'"]').click(function(){ + $(this.wrapper).on("click", 'button[list_view_doc="'+me.doctype+'"]', function(){ (me.listview.make_new_doc || me.make_new_doc)(me.doctype); }); @@ -174,7 +174,7 @@ wn.views.DocListView = wn.ui.Listing.extend({

\

', { - doctype_label: get_doctype_label(this.doctype), + doctype_label: wn._(this.doctype), doctype: this.doctype }); @@ -230,22 +230,23 @@ wn.views.DocListView = wn.ui.Listing.extend({ }); if(!dl.length) return; - if(!confirm('This is PERMANENT action and you cannot undo. Continue?')) { - return; - } - - me.set_working(true); - wn.call({ - method: 'webnotes.widgets.reportview.delete_items', - args: { - items: dl, - doctype: me.doctype - }, - callback: function() { - me.set_working(false); - me.refresh(); + + wn.confirm('This is permanent action and you cannot undo. Continue?', + function() { + me.set_working(true); + wn.call({ + method: 'webnotes.widgets.reportview.delete_items', + args: { + items: dl, + doctype: me.doctype + }, + callback: function() { + me.set_working(false); + me.refresh(); + } + }) } - }) + ); }, init_stats: function() { var me = this diff --git a/webnotes/widgets/reportview.py b/webnotes/widgets/reportview.py index be0983bad5..3891eea4e1 100644 --- a/webnotes/widgets/reportview.py +++ b/webnotes/widgets/reportview.py @@ -304,10 +304,13 @@ def delete_items(): doctype = webnotes.form_dict.get('doctype') for d in il: - dt_obj = get_obj(doctype, d) - if hasattr(dt_obj, 'on_trash'): - dt_obj.on_trash() - delete_doc(doctype, d) + try: + dt_obj = get_obj(doctype, d) + if hasattr(dt_obj, 'on_trash'): + dt_obj.on_trash() + delete_doc(doctype, d) + except Exception, e: + pass @webnotes.whitelist() def get_stats():