From a15c3bb4a31c46ac31a38e4e58ea906ab8f39596 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 19 Jun 2012 13:18:02 +0530 Subject: [PATCH 01/15] fixed: link field validate data on defocus, if autosuggest or search not used --- js/legacy/widgets/form/fields.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/js/legacy/widgets/form/fields.js b/js/legacy/widgets/form/fields.js index 110525c08e..0fcceef76d 100644 --- a/js/legacy/widgets/form/fields.js +++ b/js/legacy/widgets/form/fields.js @@ -643,10 +643,21 @@ LinkField.prototype.make_input = function() { }; $(this.txt).change(function() { - if(!$(this).val()) { + var val = $(this).val();//me.get_value(); + + me.set_input_value_executed = false; + + if(!val) { if(selector && selector.display) return; me.set_input_value(''); + } else { + // SetTimeout hack! if in put is set via autocomplete, do not validate twice + setTimeout(function() { + if (!me.set_input_value_executed) { + me.set_input_value(val); + } + }, 100); } }) } @@ -662,7 +673,7 @@ LinkField.prototype.get_custom_query = function() { LinkField.prototype.setup_buttons = function() { var me = this; - + // magnifier - search me.btn.onclick = function() { selector.set(me, me.df.options, me.df.label); @@ -701,6 +712,10 @@ LinkField.prototype.setup_buttons = function() { LinkField.prototype.set_input_value = function(val) { var me = this; + + // SetTimeout hack! if in put is set via autocomplete, do not validate twice + me.set_input_value_executed = true; + var from_selector = false; if(selector && selector.display) from_selector = true; @@ -735,7 +750,12 @@ LinkField.prototype.set_input_value = function(val) { return; } + me.validate_link(val, from_selector); +} + +LinkField.prototype.validate_link = function(val, from_selector) { // validate the value just entered + var me = this; var fetch = ''; if(cur_frm.fetch_dict[me.df.fieldname]) fetch = cur_frm.fetch_dict[me.df.fieldname].columns.join(', '); @@ -745,7 +765,7 @@ LinkField.prototype.set_input_value = function(val) { 'options':me.df.options, 'fetch': fetch }, - function(r,rt) { + function(r,rt) { if(r.message=='Ok') { // set fetch values if($(me.txt).val()!=val) { From fd402d03de2bba90e7136dc3ec720e6bee99a2d4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 21 Jun 2012 18:40:50 +0530 Subject: [PATCH 02/15] do not allow import of more than 100 supplier/customer at a time --- py/core/page/data_import_tool/data_import_tool.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/py/core/page/data_import_tool/data_import_tool.py b/py/core/page/data_import_tool/data_import_tool.py index 99665c9efb..b0f2513428 100644 --- a/py/core/page/data_import_tool/data_import_tool.py +++ b/py/core/page/data_import_tool/data_import_tool.py @@ -153,7 +153,11 @@ def upload(): # doctype doctype = rows[0][0].split(':')[1].strip() doctype_dl = webnotes.model.doctype.get(doctype, form=0) - + + if doctype in ['Customer', 'Supplier'] and len(rows[8:]) > 100: + webnotes.msgprint("Please upload only upto 100 %ss at a time" % doctype) + raise Exception + parenttype, parentfield = None, None if len(rows[1]) > 0 and ':' in rows[1][0]: parenttype = rows[1][0].split(':')[1].strip() From d51774bee95a1091aaa110a2b46b21e985dfd6d3 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 22 Jun 2012 12:12:14 +0530 Subject: [PATCH 03/15] fix in dialog: if an in_dialog doctype is called using url, it will open in form with header and sidebar --- js/legacy/widgets/form/form.js | 23 +++++++++++++---------- js/wn/views/formview.js | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/js/legacy/widgets/form/form.js b/js/legacy/widgets/form/form.js index 18b118fcb8..a30c05786a 100644 --- a/js/legacy/widgets/form/form.js +++ b/js/legacy/widgets/form/form.js @@ -43,7 +43,7 @@ wn.provide('_f'); _f.frms = {}; -_f.Frm = function(doctype, parent) { +_f.Frm = function(doctype, parent, in_form) { this.docname = ''; this.doctype = doctype; this.display = 0; @@ -61,6 +61,9 @@ _f.Frm = function(doctype, parent) { this.setup_meta(doctype); + // show in form instead of in dialog, when called using url (router.js) + this.in_form = in_form ? true : false; + // notify on rename var me = this; $(document).bind('rename', function(event, dt, old_name, new_name) { @@ -142,8 +145,8 @@ _f.Frm.prototype.onhide = function() { if(_f.cur_grid_cell) _f.cur_grid_cell.gri _f.Frm.prototype.setup_std_layout = function() { this.page_layout = new wn.PageLayout({ parent: this.wrapper, - main_width: this.meta.in_dialog ? '100%' : '75%', - sidebar_width: this.meta.in_dialog ? '0%' : '25%' + main_width: (this.meta.in_dialog && !this.in_form) ? '100%' : '75%', + sidebar_width: (this.meta.in_dialog && !this.in_form) ? '0%' : '25%' }) // only tray @@ -153,7 +156,7 @@ _f.Frm.prototype.setup_std_layout = function() { this.layout = new Layout(this.page_layout.body, '100%'); // sidebar - if(this.meta.in_dialog) { + if(this.meta.in_dialog && !this.in_form) { // hide sidebar $(this.page_layout.wrapper).removeClass('layout-wrapper-background'); $(this.page_layout.main).removeClass('layout-main-section'); @@ -168,7 +171,7 @@ _f.Frm.prototype.setup_std_layout = function() { // header - no headers for tables and guests - if(!(this.meta.istable || user=='Guest' || this.meta.in_dialog)) + if(!(this.meta.istable || user=='Guest' || (this.meta.in_dialog && !this.in_form))) this.frm_head = new _f.FrmHeader(this.page_layout.head, this); // bg colour @@ -246,7 +249,7 @@ _f.Frm.prototype.email_doc = function() { _f.Frm.prototype.rename_notify = function(dt, old, name) { // from form - if(this.meta.in_dialog) + if(this.meta.in_dialog && !this.in_form) return; if(this.docname == old) @@ -276,7 +279,7 @@ _f.Frm.prototype.rename_notify = function(dt, old, name) { // ====================================================================================== -_f.Frm.prototype.setup_meta = function() { +_f.Frm.prototype.setup_meta = function(doctype) { this.meta = get_local('DocType',this.doctype); this.perm = get_perm(this.doctype); // for create if(this.meta.istable) { this.meta.in_dialog = 1 } @@ -471,7 +474,7 @@ _f.Frm.prototype.get_doc_perms = function() { _f.Frm.prototype.refresh_header = function() { // set title // main title - if(!this.meta.in_dialog) { + if(!this.meta.in_dialog || this.in_form) { set_title(this.meta.issingle ? this.doctype : this.docname); } @@ -514,7 +517,7 @@ _f.Frm.prototype.check_doc_perm = function() { _f.Frm.prototype.refresh = function(docname) { // record switch if(docname) { - if(this.docname != docname && !this.meta.in_dialog && !this.meta.istable) scroll(0, 0); + if(this.docname != docname && (!this.meta.in_dialog || this.in_form) && !this.meta.istable) scroll(0, 0); this.docname = docname; } if(!this.meta.istable) { @@ -613,7 +616,7 @@ _f.Frm.prototype.refresh = function(docname) { _f.Frm.prototype.refresh_footer = function() { var f = this.page_layout.footer; if(f.save_area) { - if(get_url_arg('embed') || (this.editable && !this.meta.in_dialog && this.doc.docstatus==0 && !this.meta.istable && this.get_doc_perms()[WRITE])) { + if(get_url_arg('embed') || (this.editable && (!this.meta.in_dialog || this.in_form) && this.doc.docstatus==0 && !this.meta.istable && this.get_doc_perms()[WRITE])) { f.show_save(); } else { f.hide_save(); diff --git a/js/wn/views/formview.js b/js/wn/views/formview.js index fff3bef332..b6c6926c04 100644 --- a/js/wn/views/formview.js +++ b/js/wn/views/formview.js @@ -19,7 +19,7 @@ wn.views.formview = { } if(!wn.views.formview[dt]) { wn.views.formview[dt] = wn.container.add_page('Form - ' + dt); - wn.views.formview[dt].frm = new _f.Frm(dt, wn.views.formview[dt]); + wn.views.formview[dt].frm = new _f.Frm(dt, wn.views.formview[dt], true); } wn.container.change_to('Form - ' + dt); wn.views.formview[dt].frm.refresh(dn); From 1a079ca19ccac0b29dc89650b46e59feb3067669 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 22 Jun 2012 12:16:03 +0530 Subject: [PATCH 04/15] Error fixed in new report: sort by child table column --- js/wn/views/reportview.js | 10 +++++++--- py/webnotes/widgets/doclistview.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/js/wn/views/reportview.js b/js/wn/views/reportview.js index c2201fc3c3..7c20d57b46 100644 --- a/js/wn/views/reportview.js +++ b/js/wn/views/reportview.js @@ -192,17 +192,21 @@ wn.views.ReportView = wn.ui.Listing.extend({ get_order_by: function() { // first - var order_by = this.get_full_column_name([this.sort_by_select.val()]) + var order_by = this.get_selected_table_and_column(this.sort_by_select) + ' ' + this.sort_order_select.val() - + // second if(this.sort_by_next_select.val()) { - order_by += ', ' + this.get_full_column_name([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_selected_table_and_column: function($select) { + return this.get_full_column_name([$select.val(), + $select.find('option:selected').attr('table')]) + }, // get table_name.column_name get_full_column_name: function(v) { diff --git a/py/webnotes/widgets/doclistview.py b/py/webnotes/widgets/doclistview.py index f1d9df43a5..d55801fa9a 100644 --- a/py/webnotes/widgets/doclistview.py +++ b/py/webnotes/widgets/doclistview.py @@ -55,8 +55,10 @@ def get(arg=None): data['tables'] = ', '.join(tables) data['conditions'] = ' and '.join(conditions) data['fields'] = ', '.join(fields) + if not data.get('order_by'): data['order_by'] = tables[0] + '.modified desc' + check_sort_by_table(data.get('order_by'), tables) add_limit(data) @@ -64,6 +66,15 @@ def get(arg=None): order by %(order_by)s %(limit)s""" % data return webnotes.conn.sql(query, as_dict=1) +def check_sort_by_table(sort_by, tables): + """check atleast 1 column selected from the sort by table """ + tbl = sort_by.split('.')[0] + if tbl not in tables: + if tbl.startswith('`'): + tbl = tbl[4:-1] + webnotes.msgprint("Please select atleast 1 column from '%s' to sort"\ + % tbl, raise_exception=1) + def run_custom_query(data): """run custom query""" query = data['query'] From c7a7413cc623bebb13f3827fcc6acc6f75e2489d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 25 Jun 2012 13:18:42 +0530 Subject: [PATCH 05/15] run the report only if route changes --- js/legacy/widgets/report_builder/report_builder.js | 2 ++ js/wn/views/reportview.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/legacy/widgets/report_builder/report_builder.js b/js/legacy/widgets/report_builder/report_builder.js index 1f110cdacd..9d7d1ef60c 100644 --- a/js/legacy/widgets/report_builder/report_builder.js +++ b/js/legacy/widgets/report_builder/report_builder.js @@ -478,6 +478,8 @@ _r.ReportBuilder.prototype.setup_filters_and_cols = function() { _r.ReportBuilder.prototype.set_filters_from_route = function() { // add filters from route var route = wn.get_route(); + //save this for checking changes in filter + this.current_route = wn.get_route_str(); if(route.length>3) { for(var i=3; i Date: Mon, 25 Jun 2012 20:05:19 +0530 Subject: [PATCH 06/15] clear locals and then sync locals when whole doclist is passed --- js/core.min.js | 2 +- js/legacy/model/local_data.js | 13 ++++++++++ js/legacy/widgets/form/clientscriptAPI.js | 2 +- js/legacy/widgets/form/form.js | 2 +- js/wn/request.js | 4 ++- .../doctype/customize_form/customize_form.py | 2 +- .../property_setter/property_setter.comp.js | 4 +-- .../property_setter/property_setter.js | 4 +-- .../system_console/system_console.comp.js | 2 +- .../doctype/system_console/system_console.js | 2 +- py/webnotes/model/doc.py | 25 +++++++++++-------- py/webnotes/model/doclist.py | 9 +++++-- py/webnotes/widgets/form/save.py | 1 + wnf.py | 1 + 14 files changed, 50 insertions(+), 23 deletions(-) diff --git a/js/core.min.js b/js/core.min.js index 5d7b6f7cc1..0636d984e3 100644 --- a/js/core.min.js +++ b/js/core.min.js @@ -274,7 +274,7 @@ wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(op return;} if(r.server_messages)msgprint(r.server_messages) if(r.exc){console.log(r.exc);};if(r['403']){wn.container.change_to('403');} -if(r.docs)LocalDB.sync(r.docs);} +if(r.docs){LocalDB.sync(r.docs);}} wn.request.call=function(opts){wn.request.prepare(opts);$.ajax({url:opts.url||wn.request.url,data:opts.args,type:opts.type||'POST',dataType:opts.dataType||'json',success:function(r,xhr){wn.request.cleanup(opts,r);opts.success(r,xhr.responseText);},error:function(xhr,textStatus){wn.request.cleanup(opts,{});show_alert('Unable to complete request: '+textStatus) if(opts.error)opts.error(xhr)}})} wn.call=function(opts){var args=$.extend({},opts.args) diff --git a/js/legacy/model/local_data.js b/js/legacy/model/local_data.js index 6b6fcccfc6..03cafc6bc7 100644 --- a/js/legacy/model/local_data.js +++ b/js/legacy/model/local_data.js @@ -77,6 +77,9 @@ function get_local(dt, dn) { return locals[dt] ? locals[dt][dn] : null; } LocalDB.sync = function(list) { if(list._kl)list = expand_doclist(list); + if (list) { + LocalDB.clear_locals(list[0].doctype, list[0].name); + } for(var i=0;i Date: Tue, 26 Jun 2012 12:46:58 +0530 Subject: [PATCH 07/15] get list of system managers function --- py/webnotes/utils/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/py/webnotes/utils/__init__.py b/py/webnotes/utils/__init__.py index b04e1c18f0..616f647c63 100644 --- a/py/webnotes/utils/__init__.py +++ b/py/webnotes/utils/__init__.py @@ -683,3 +683,18 @@ def get_label_doctype(label): WHERE dt_label=%s""", label) return res and res[0][0] or label + + +def get_system_managers_list(): + """Returns a list of system managers' email addresses""" + system_managers_list = webnotes.conn.sql("""\ + SELECT DISTINCT p.name + FROM tabUserRole ur, tabProfile p + WHERE + ur.parent = p.name AND + ur.role='System Manager' AND + p.docstatus<2 AND + p.enabled=1 AND + p.name not in ('Administrator', 'Guest')""", as_list=1) + + return [sysman[0] for sysman in system_managers_list] From bf52d17ca97394de590032a7c4f447dbf4493414 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Jun 2012 12:58:30 +0530 Subject: [PATCH 08/15] shifted 'when' date manipulation into a seperate method, fixes in new doc logic of doclistview --- js/wn/views/doclistview.js | 51 +++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/js/wn/views/doclistview.js b/js/wn/views/doclistview.js index ccfc9af269..664695f943 100644 --- a/js/wn/views/doclistview.js +++ b/js/wn/views/doclistview.js @@ -124,6 +124,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ this.allow_delete = true; }, init_list: function(auto_run) { + var me = this; // init list this.make({ method: 'webnotes.widgets.doclistview.get', @@ -138,20 +139,30 @@ wn.views.DocListView = wn.ui.Listing.extend({ no_result_message: this.make_no_result(), columns: this.listview.fields }); + + // 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(){ + me.make_new_doc(me.doctype); + }); + if((auto_run !== false) && (auto_run !== 0)) this.run(); }, + make_no_result: function() { - return repl('

No %(doctype_label)s found

\ + var no_result_message = repl('
\ +

No %(doctype_label)s found

\ %(description)s\
\ -

\ +

\

', { doctype_label: get_doctype_label(this.doctype), doctype: this.doctype, - description: wn.markdown(locals.DocType[this.doctype].description || '') + description: wn.markdown(locals.DocType[this.doctype].description || ''), }); + + return no_result_message; }, render_row: function(row, data) { data.doctype = this.doctype; @@ -431,18 +442,7 @@ wn.views.ListView = Class.extend({ data.fullname = wn.user_info(data.owner).fullname; data.avatar = wn.user_info(data.owner).image; - // when - data.when = dateutil.str_to_user(data.modified).split(' ')[0]; - var diff = dateutil.get_diff(dateutil.get_today(), data.modified.split(' ')[0]); - if(diff==0) { - data.when = dateutil.comment_when(data.modified); - } - if(diff == 1) { - data.when = 'Yesterday' - } - if(diff == 2) { - data.when = '2 days ago' - } + this.prepare_when(data, data.modified); // docstatus if(data.docstatus==0 || data.docstatus==null) { @@ -463,6 +463,23 @@ wn.views.ListView = Class.extend({ } } }, + + prepare_when: function(data, date_str) { + if (!date_str) date_str = data.modified; + // when + data.when = dateutil.str_to_user(date_str).split(' ')[0]; + var diff = dateutil.get_diff(dateutil.get_today(), date_str.split(' ')[0]); + if(diff==0) { + data.when = dateutil.comment_when(date_str); + } + if(diff == 1) { + data.when = 'Yesterday' + } + if(diff == 2) { + data.when = '2 days ago' + } + }, + add_user_tags: function(parent, data) { var me = this; if(data._user_tags) { From 1370ce6f1e9a386c6de57058cb98cee580b7ec1c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 28 Jun 2012 18:13:23 +0530 Subject: [PATCH 09/15] escape character error fixed in dt mapper --- .../doctype/doctype_mapper/doctype_mapper.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/py/core/doctype/doctype_mapper/doctype_mapper.py b/py/core/doctype/doctype_mapper/doctype_mapper.py index bcabd6db15..4bbca8e9ea 100644 --- a/py/core/doctype/doctype_mapper/doctype_mapper.py +++ b/py/core/doctype/doctype_mapper/doctype_mapper.py @@ -267,18 +267,15 @@ class DocType: cur_val = '%.2f' % flt(cur_val) if cl['op'] == '=' and to_flds[cl['to_fld']]['fieldtype'] in ['Currency', 'Float']: - consistent = sql("""\ - select name, %s from `tab%s` - where name = "%s" and "%s" - %s <= 0.5""" \ - % (cl['from_fld'], t.from_table, child_obj.fields[t.reference_key], - flt(cur_val), cl['from_fld'])) + consistent = sql("""select name, %s from `tab%s` \ + where name = %s and %s - %s <= 0.5"""% (cl['from_fld'], t.from_table, '%s', '%s', \ + cl['from_fld']), (child_obj.fields[t.reference_key], flt(cur_val))) else: - consistent = sql("""\ - select name, %s from `tab%s` - where name = "%s" and "%s" %s ifnull(%s, '')""" \ - % (cl['from_fld'], t.from_table, child_obj.fields[t.reference_key], \ + consistent = sql("""select name, %s from `tab%s` \ + where name = %s and %s %s ifnull(%s, '')""" % (cl['from_fld'], t.from_table, \ + '%s', '%s', cl['op'], cl['from_fld']), (child_obj.fields[t.reference_key], \ to_flds[cl['to_fld']]['fieldtype'] in ('Currency', 'Float', 'Int') \ - and flt(cur_val) or cstr(cur_val), cl['op'], cl['from_fld'])) + and flt(cur_val) or cstr(cur_val))) if not self.ref_doc: det = sql("""select name, parent from `tab%s` where name = \"%s\"""" % (t.from_table, child_obj.fields[t.reference_key])) From ea0a8ce616774d3cdfd127e415c1211378a000da Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 28 Jun 2012 20:47:02 +0530 Subject: [PATCH 10/15] fixes in cacheitem table --- py/webnotes/install_lib/install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/webnotes/install_lib/install.py b/py/webnotes/install_lib/install.py index d4b5ed428f..fa513958f8 100755 --- a/py/webnotes/install_lib/install.py +++ b/py/webnotes/install_lib/install.py @@ -142,8 +142,8 @@ class Installer: webnotes.conn.sql("""create table __CacheItem( `key` VARCHAR(180) NOT NULL PRIMARY KEY, `value` LONGTEXT, - `expires_on` TIMESTAMP - )""") + `expires_on` DATETIME + ) ENGINE=MyISAM DEFAULT CHARSET=utf8""") From 591456df4f16f930bbe6eb248e5af181dcf5e629 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 29 Jun 2012 16:38:35 +0530 Subject: [PATCH 11/15] change in delete button logic of sidebar --- js/legacy/widgets/form/form.js | 2 +- js/legacy/wn/widgets/form/sidebar.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/legacy/widgets/form/form.js b/js/legacy/widgets/form/form.js index bbe636e4b2..a0b05e71d3 100644 --- a/js/legacy/widgets/form/form.js +++ b/js/legacy/widgets/form/form.js @@ -1078,7 +1078,7 @@ _f.Frm.prototype.savetrash = function() { if(wn.ui.toolbar.recent) wn.ui.toolbar.recent.remove(me.doctype, me.docname); // "close" - window.back(); + window.history.back(); } }) } diff --git a/js/legacy/wn/widgets/form/sidebar.js b/js/legacy/wn/widgets/form/sidebar.js index 15577bdb53..70dc021fad 100644 --- a/js/legacy/wn/widgets/form/sidebar.js +++ b/js/legacy/wn/widgets/form/sidebar.js @@ -89,8 +89,8 @@ wn.widgets.form.sidebar = { Sidebar: function(form) { type: 'link', label: 'Delete', display: function() { - return me.form.meta.allow_trash && cint(me.form.doc.docstatus) != 2 - && (!me.form.doc.__islocal) && me.form.perm[0][CANCEL] + return (cint(me.form.doc.docstatus) != 1) && !me.form.doc.__islocal + && wn.model.can_delete(me.form.doctype); }, icon: 'icon-remove-sign', onclick: function() { me.form.savetrash() } From 3ac7bf6430a0e4cdd677768d44a3d72c5f174c3b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 29 Jun 2012 18:08:55 +0530 Subject: [PATCH 12/15] show child table values in doclistview --- py/webnotes/widgets/doclistview.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/py/webnotes/widgets/doclistview.py b/py/webnotes/widgets/doclistview.py index d55801fa9a..c7a633b61c 100644 --- a/py/webnotes/widgets/doclistview.py +++ b/py/webnotes/widgets/doclistview.py @@ -58,12 +58,19 @@ 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" + else: + data['group_by'] = '' + check_sort_by_table(data.get('order_by'), tables) add_limit(data) query = """select %(fields)s from %(tables)s where %(conditions)s - order by %(order_by)s %(limit)s""" % data + %(group_by)s order by %(order_by)s %(limit)s""" % data + return webnotes.conn.sql(query, as_dict=1) def check_sort_by_table(sort_by, tables): @@ -132,7 +139,7 @@ def build_conditions(filters): # match conditions build_match_conditions(data, conditions) - + return conditions def build_filter_conditions(data, filters, conditions): @@ -175,6 +182,8 @@ def get_tables(): # add tables from fields for f in json.loads(data['fields']): table_name = f.split('.')[0] + if table_name.lower().startswith('group_concat('): + table_name = table_name[13:] # check if ifnull function is used if table_name.lower().startswith('ifnull('): table_name = table_name[7:] From 8e7facf344d0c4e5270a5da1b69c02b5eb6f596b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sun, 1 Jul 2012 20:06:59 +0530 Subject: [PATCH 13/15] Update master --- wnf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wnf.py b/wnf.py index 884f80ccc1..9e30f91351 100755 --- a/wnf.py +++ b/wnf.py @@ -55,7 +55,7 @@ def search_replace_with_prompt(fpath, txt1, txt2): tmp = [] for c in content: if c.find(txt1) != -1: - print '\n', fpath + print fpath print colored(txt1, 'red').join(c[:-1].split(txt1)) a = '' while a.lower() not in ['y', 'n', 'skip']: From 0955b88070737d15973db1c20f0662a8c92cd885 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 2 Jul 2012 20:25:57 +0530 Subject: [PATCH 14/15] fix: changed Module to type Suggest --- py/core/doctype/doctype/doctype.txt | 47 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/py/core/doctype/doctype/doctype.txt b/py/core/doctype/doctype/doctype.txt index 406d0b5fa1..351f5006c0 100644 --- a/py/core/doctype/doctype/doctype.txt +++ b/py/core/doctype/doctype/doctype.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-14 17:04:27', + 'creation': '2012-05-15 12:14:22', 'docstatus': 0, - 'modified': '2012-04-15 08:53:32', + 'modified': '2012-07-02 20:14:52', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -30,7 +30,7 @@ 'section_style': u'Simple', 'server_code_error': u' ', 'show_in_menu': 0, - 'version': 13 + 'version': 1 }, # These values are common for all DocField @@ -45,12 +45,15 @@ # These values are common for all DocPerm { + 'amend': 0, + 'cancel': 0, 'doctype': u'DocPerm', 'name': '__common__', 'parent': u'DocType', 'parentfield': u'permissions', 'parenttype': u'DocType', - 'read': 1 + 'read': 1, + 'submit': 0 }, # DocType, DocType @@ -61,34 +64,30 @@ # DocPerm { - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'System Manager' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'System Manager' - }, - - # DocPerm - { - 'cancel': 0, 'create': 1, 'doctype': u'DocPerm', 'permlevel': 0, - 'role': u'Administrator', - 'submit': 0, + 'role': u'System Manager', 'write': 1 }, # DocPerm { + 'create': 1, + 'doctype': u'DocPerm', + 'execute': 0, + 'permlevel': 0, + 'role': u'Administrator', + 'write': 1 + }, + + # DocPerm + { + 'create': 0, 'doctype': u'DocPerm', 'permlevel': 1, - 'role': u'Administrator' + 'role': u'Administrator', + 'write': 0 }, # DocField @@ -117,11 +116,11 @@ { 'doctype': u'DocField', 'fieldname': u'module', - 'fieldtype': u'Link', + 'fieldtype': u'Data', 'label': u'Module', 'oldfieldname': u'module', 'oldfieldtype': u'Link', - 'options': u'Module Def', + 'options': u'Suggest', 'reqd': 1 }, From de4f1ef3a7bb5b885a3d45835766b7837eff2978 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 3 Jul 2012 12:33:02 +0530 Subject: [PATCH 15/15] fix in data import - if a blank row is encountered, ignore it --- py/core/page/data_import_tool/data_import_tool.py | 1 + 1 file changed, 1 insertion(+) diff --git a/py/core/page/data_import_tool/data_import_tool.py b/py/core/page/data_import_tool/data_import_tool.py index b0f2513428..d3d18286bf 100644 --- a/py/core/page/data_import_tool/data_import_tool.py +++ b/py/core/page/data_import_tool/data_import_tool.py @@ -181,6 +181,7 @@ def upload(): delete_child_rows(rows, doctype) for row in rows[8:]: + if not row: continue d = dict(zip(columns, row[1:])) d['doctype'] = doctype