diff --git a/js/legacy/widgets/form/form.js b/js/legacy/widgets/form/form.js index 634733ff4c..b2eaefdf45 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' } @@ -542,11 +542,16 @@ _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); + } // set the doc this.doc = get_local(this.doctype, this.docname); @@ -759,7 +764,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 diff --git a/js/wn/views/doclistview.js b/js/wn/views/doclistview.js index 7827ccdc47..41a437f1d7 100644 --- a/js/wn/views/doclistview.js +++ b/js/wn/views/doclistview.js @@ -184,6 +184,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/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 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'] = ''