From a0f7317b5c9335b57cb741f74785d323726f4155 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jul 2012 15:43:48 +0530 Subject: [PATCH 1/3] fix in doclistview group by logic --- js/wn/views/doclistview.js | 1 + py/webnotes/widgets/doclistview.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/wn/views/doclistview.js b/js/wn/views/doclistview.js index aad2fa8b7f..983e60e744 100644 --- a/js/wn/views/doclistview.js +++ b/js/wn/views/doclistview.js @@ -179,6 +179,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ docstatus: this.can_submit ? $.map(this.$page.find('.show-docstatus :checked'), function(inp) { return $(inp).attr('data-docstatus') }) : [], order_by: this.listview.order_by || undefined, + group_by: this.listview.group_by || undefined, } }, add_delete_option: function() { diff --git a/py/webnotes/widgets/doclistview.py b/py/webnotes/widgets/doclistview.py index c7a633b61c..0a176814cb 100644 --- a/py/webnotes/widgets/doclistview.py +++ b/py/webnotes/widgets/doclistview.py @@ -58,9 +58,9 @@ 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" + + if data.get('group_by'): + data['group_by'] = "group by " + data.get('group_by') else: data['group_by'] = '' From e2e0fd93169af434d6327259209366b9eb254e3f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jul 2012 20:10:48 +0530 Subject: [PATCH 2/3] do not allow opening doctype when listview is open --- js/legacy/widgets/form/form.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/js/legacy/widgets/form/form.js b/js/legacy/widgets/form/form.js index a5b045bbc0..a654a3cef2 100644 --- a/js/legacy/widgets/form/form.js +++ b/js/legacy/widgets/form/form.js @@ -80,12 +80,12 @@ _f.Frm.prototype.check_doctype_conflict = function(docname) { if(this.doctype=='DocType' && docname=='DocType') { msgprint('Allowing DocType, DocType. Be careful!') } else if(this.doctype=='DocType') { - if(wn.views.formview[docname]) { + if (wn.views.formview[docname] || wn.pages['List/'+docname]) { msgprint("Cannot open DocType when its instance is open") throw 'doctype open conflict' } } else { - if(wn.views.formview.DocType && wn.views.formview.DocType.frm.opendocs[this.doctype]) { + if (wn.views.formview.DocType && wn.views.formview.DocType.frm.opendocs[this.doctype]) { msgprint("Cannot open instance when its DocType is open") throw 'doctype open conflict' } @@ -524,20 +524,25 @@ _f.Frm.prototype.refresh = function(docname) { cur_frm = this; this.parent.cur_frm = this; } - + if(this.docname) { // document to show // check permissions if(!this.check_doc_perm()) return; + + // check if doctype is already open + if (!this.opendocs[this.docname]) { + this.check_doctype_conflict(this.docname); + } // do setup if(!this.setup_done) this.setup(); // set customized permissions for this record this.runclientscript('set_perm',this.doctype, this.docname); - + // set the doc - this.doc = get_local(this.doctype, this.docname); + this.doc = get_local(this.doctype, this.docname); // load the record for the first time, if not loaded (call 'onload') cur_frm.cscript.is_onload = false; @@ -738,7 +743,8 @@ _f.Frm.prototype.refresh_dependency = function() { // ====================================================================================== _f.Frm.prototype.setnewdoc = function(docname) { - this.check_doctype_conflict(docname); + // moved this call to refresh function + // this.check_doctype_conflict(docname); // if loaded if(this.opendocs[docname]) { // already exists From 01f8e44caee20f4c69dffd47e156e13525f3d1be Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Jul 2012 20:24:55 +0530 Subject: [PATCH 3/3] Changed file names from listview.js to doctype_name_list.js --- py/core/doctype/report/{listview.js => report_list.js} | 0 .../search_criteria/{listview.js => search_criteria_list.js} | 0 py/webnotes/model/doctype.py | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename py/core/doctype/report/{listview.js => report_list.js} (100%) rename py/core/doctype/search_criteria/{listview.js => search_criteria_list.js} (100%) diff --git a/py/core/doctype/report/listview.js b/py/core/doctype/report/report_list.js similarity index 100% rename from py/core/doctype/report/listview.js rename to py/core/doctype/report/report_list.js diff --git a/py/core/doctype/search_criteria/listview.js b/py/core/doctype/search_criteria/search_criteria_list.js similarity index 100% rename from py/core/doctype/search_criteria/listview.js rename to py/core/doctype/search_criteria/search_criteria_list.js diff --git a/py/webnotes/model/doctype.py b/py/webnotes/model/doctype.py index bb265f69d6..428b90520b 100644 --- a/py/webnotes/model/doctype.py +++ b/py/webnotes/model/doctype.py @@ -275,7 +275,7 @@ class _DocType: _add_code(scrub(doc.name) + '.js', '__js') _add_code(scrub(doc.name) + '.css', '__css') - _add_code('listview.js', '__listjs') + _add_code('%s_list.js' % scrub(doc.name), '__listjs') _add_code('help.md', 'description') # embed all require files