From 0a039bb90a2a4fda605b1af47f412edcbb3a5608 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 1 May 2013 11:23:43 +0530 Subject: [PATCH 01/13] [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/13] [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 f324ac8716136e76857d2a781a09f82b32dcb590 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 2 May 2013 08:55:01 +0530 Subject: [PATCH 03/13] [email lib] [receive] import webnotes --- webnotes/utils/email_lib/receive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webnotes/utils/email_lib/receive.py b/webnotes/utils/email_lib/receive.py index 3d4a448c46..320239ba5b 100644 --- a/webnotes/utils/email_lib/receive.py +++ b/webnotes/utils/email_lib/receive.py @@ -21,6 +21,7 @@ # from __future__ import unicode_literals +import webnotes from webnotes.utils import extract_email_id, convert_utc_to_user_timezone class IncomingMail: @@ -31,7 +32,6 @@ class IncomingMail: import email import email.utils import datetime - import time self.mail = email.message_from_string(content) From 5561b6a5948399a32438e15c6bf413480487d89c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 2 May 2013 08:55:32 +0530 Subject: [PATCH 04/13] [scheduler] [logging] when logging, if no connection, create a new connection --- webnotes/utils/scheduler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/webnotes/utils/scheduler.py b/webnotes/utils/scheduler.py index eeeff28d24..c99b81c3bb 100644 --- a/webnotes/utils/scheduler.py +++ b/webnotes/utils/scheduler.py @@ -96,6 +96,10 @@ def trigger(method): def log(method): """log error in patch_log""" import webnotes + + if not (webnotes.conn and webnotes.conn._conn): + webnotes.connect() + webnotes.conn.rollback() traceback = webnotes.getTraceback() From c4ab2bbc76a304b5467f7fc00b7e5dc6f4a66494 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 2 May 2013 10:01:18 +0530 Subject: [PATCH 05/13] [scheduler] [fix] save scheduler_last_event at the start of scheduler --- webnotes/utils/scheduler.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/webnotes/utils/scheduler.py b/webnotes/utils/scheduler.py index c99b81c3bb..7a00334692 100644 --- a/webnotes/utils/scheduler.py +++ b/webnotes/utils/scheduler.py @@ -52,14 +52,19 @@ def execute(): out = [] - # if first task of the day execute daily tasks nowtime = webnotes.utils.now_datetime() last = webnotes.conn.get_global('scheduler_last_event') + + # set scheduler last event + webnotes.conn.begin() + webnotes.conn.set_global('scheduler_last_event', nowtime.strftime(format)) + webnotes.conn.commit() + if last: last = datetime.strptime(last, format) if nowtime.day != last.day: - + # if first task of the day execute daily tasks out.append('daily:' + trigger('execute_daily')) if nowtime.month != last.month: @@ -73,10 +78,6 @@ def execute(): out.append('all:' + trigger('execute_all')) - webnotes.conn.begin() - webnotes.conn.set_global('scheduler_last_event', nowtime.strftime(format)) - webnotes.conn.commit() - return '\n'.join(out) def trigger(method): @@ -90,7 +91,7 @@ def trigger(method): webnotes.conn.commit() return 'ok' - except Exception, e: + except Exception: return log(method) def log(method): From 6c916cfe8e81c83853420ac8009fd42132ad3f40 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 2 May 2013 11:34:05 +0530 Subject: [PATCH 06/13] [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 07/13] [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 08/13] [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 09/13] [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 10/13] [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 %}