From 0a039bb90a2a4fda605b1af47f412edcbb3a5608 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2013 11:23:43 +0530 Subject: [PATCH 01/11] [script report] bank reconciliation statement in new style --- webnotes/widgets/query_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webnotes/widgets/query_report.py b/webnotes/widgets/query_report.py index b156e765ea..7b58a07b16 100644 --- a/webnotes/widgets/query_report.py +++ b/webnotes/widgets/query_report.py @@ -68,7 +68,7 @@ def run(report_name, filters=None): + ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute" columns, result = webnotes.get_method(method_name)(filters or {}) - if cint(report.add_total_row): + if cint(report.add_total_row) and result: result = add_total_row(result, columns) return { From 1f31dfa6e8db6ca3bd11f039b71f117d50c6396f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2013 15:49:07 +0530 Subject: [PATCH 02/11] [fixes] button hide --- public/js/legacy/widgets/form/fields.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/js/legacy/widgets/form/fields.js b/public/js/legacy/widgets/form/fields.js index 06b477e9f3..48c98b6fc2 100644 --- a/public/js/legacy/widgets/form/fields.js +++ b/public/js/legacy/widgets/form/fields.js @@ -1295,11 +1295,11 @@ _f.ButtonField.prototype.make_input = function() { var me = this; } _f.ButtonField.prototype.hide = function() { - $dh(this.button_area); + $dh(this.wrapper); }; _f.ButtonField.prototype.show = function() { - $ds(this.button_area); + $ds(this.wrapper); }; From 6c916cfe8e81c83853420ac8009fd42132ad3f40 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 May 2013 11:34:05 +0530 Subject: [PATCH 03/11] [doclist] [filters] added truthsy falsy fitlers --- webnotes/model/doclist.py | 9 +++++++-- webnotes/utils/__init__.py | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/webnotes/model/doclist.py b/webnotes/model/doclist.py index ca42e82f8a..7bbbc54b1f 100644 --- a/webnotes/model/doclist.py +++ b/webnotes/model/doclist.py @@ -29,7 +29,8 @@ class DocList(list): def get(self, filters, limit=0): """pass filters as: {"key": "val", "key": ["!=", "val"], - "key": ["in", "val"], "key": ["not in", "val"], "key": "^val"}""" + "key": ["in", "val"], "key": ["not in", "val"], "key": "^val", + "key" : True (exists), "key": False (does not exist) }""" out = [] @@ -39,7 +40,11 @@ class DocList(list): for f in filters: fval = filters[f] - if not isinstance(fval, list): + if fval==True: + fval = ["not None", fval] + elif fval==False: + fval = ["None", fval] + elif not isinstance(fval, list): if isinstance(fval, basestring) and fval.startswith("^"): fval = ["^", fval[1:]] else: diff --git a/webnotes/utils/__init__.py b/webnotes/utils/__init__.py index 2a94c130a0..fa31b9c502 100644 --- a/webnotes/utils/__init__.py +++ b/webnotes/utils/__init__.py @@ -825,6 +825,8 @@ operator_map = { "<": lambda (a, b): operator.lt(a, b), ">=": lambda (a, b): operator.ge(a, b), "<=": lambda (a, b): operator.le(a, b), + "not None": lambda (a, b): a and True or False, + "None": lambda (a, b): (not a) and True or False } def compare(val1, condition, val2): From 8c18d836ba7c2e40e24882a5b7b30ef1e60c48d6 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 May 2013 11:45:03 +0530 Subject: [PATCH 04/11] [communication/email] [usability] close dialog after successful send, user will not lose text --- public/js/wn/views/communication.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/js/wn/views/communication.js b/public/js/wn/views/communication.js index 935eca8791..aac4f66b7b 100644 --- a/public/js/wn/views/communication.js +++ b/public/js/wn/views/communication.js @@ -205,7 +205,6 @@ wn.views.CommunicationComposer = Class.extend({ }) _p.build(form_values.select_print_format || "", function(print_format_html) { - me.dialog.hide(); if(form_values.attach_document_print) { var print_html = print_format_html if(cint(wn.boot.send_print_in_body_and_attachment)) { @@ -238,7 +237,10 @@ wn.views.CommunicationComposer = Class.extend({ if(!r.exc) { if(form_values.send_email) msgprint("Email sent to " + form_values.recipients); + me.dialog.hide(); cur_frm.reload_doc(); + } else { + msgprint("There were errors while sending email. Please try again.") } } }); From c03e22c2db51ffd0abd3e8aef4a9227d7a43b64a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 May 2013 14:22:40 +0530 Subject: [PATCH 05/11] [doclist] new pattern / [item] pricelist must be unique / [formatter] show null floats as empty string --- public/js/wn/form/formatters.js | 3 ++- webnotes/db.py | 8 ++++++++ webnotes/model/doclist.py | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/public/js/wn/form/formatters.js b/public/js/wn/form/formatters.js index 0041ad7c0d..9b62596e16 100644 --- a/public/js/wn/form/formatters.js +++ b/public/js/wn/form/formatters.js @@ -11,7 +11,8 @@ wn.form.formatters = { parseInt(wn.boot.sysdefaults.float_precision) : null; return "
" + - format_number(value, null, decimals) + "
"; + ((value==null || value==="") ? "" : + format_number(value, null, decimals)) + ""; }, Int: function(value) { return cint(value); diff --git a/webnotes/db.py b/webnotes/db.py index d3007a7ce3..6db5fdc829 100644 --- a/webnotes/db.py +++ b/webnotes/db.py @@ -309,6 +309,9 @@ class Database: return ret and ((len(ret[0]) > 1 or as_dict) and ret[0] or ret[0][0]) or None def get_values(self, doctype, filters=None, fieldname="name", ignore=None, as_dict=False, debug=False): + if isinstance(filters, list): + return self.get_value_for_many_names(doctype, filters, fieldname) + fields = fieldname if fieldname!="*": if isinstance(fieldname, basestring): @@ -367,6 +370,11 @@ class Database: return r + def get_value_for_many_names(self, doctype, names, field): + names = filter(None, names) + return dict(self.sql("select name, `%s` from `tab%s` where name in (%s)" \ + % (field, doctype, ", ".join(map(lambda n: "'%s'" % n.replace("'", "\'"), names))))) + def set_value(self, dt, dn, field, val, modified=None, modified_by=None): from webnotes.utils import now if dn and dt!=dn: diff --git a/webnotes/model/doclist.py b/webnotes/model/doclist.py index 7bbbc54b1f..9c7c626736 100644 --- a/webnotes/model/doclist.py +++ b/webnotes/model/doclist.py @@ -60,6 +60,9 @@ class DocList(list): break return DocList(out) + + def get_distinct_values(self, fieldname): + return list(set(map(lambda d: d.fields.get(fieldname), self))) def remove_items(self, filters): for d in self.get(filters): From 53c720a9c84431d8ede6ab721623f2fa2d052442 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 May 2013 15:36:33 +0530 Subject: [PATCH 06/11] [item] [naming] by series or code / [naming series] optionally set number of digits --- webnotes/model/doc.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webnotes/model/doc.py b/webnotes/model/doc.py index f27f23d2b4..3b2313ddbb 100755 --- a/webnotes/model/doc.py +++ b/webnotes/model/doc.py @@ -536,11 +536,14 @@ def make_autoname(key, doctype=''): """ n = '' l = key.split('.') + series_set = False for e in l: en = '' if e.startswith('#'): - digits = len(e) - en = getseries(n, digits, doctype) + if not series_set: + digits = len(e) + en = getseries(n, digits, doctype) + series_set = True elif e=='YY': import time en = time.strftime('%y') From fccfa680bb543077ca5762b400aae781b9bbb2cf Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 2 May 2013 15:51:45 +0530 Subject: [PATCH 07/11] [login] [disable signup] option to disable signup link in login page --- templates/pages/login.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/pages/login.html b/templates/pages/login.html index 4ae23a0df2..bc748fe4f8 100644 --- a/templates/pages/login.html +++ b/templates/pages/login.html @@ -46,9 +46,12 @@

Forgot Password

+ + {% if not disable_signup %}

New user? Sign Up

+ {% endif %}