This commit is contained in:
Akhilesh Darjee 2013-05-06 18:13:54 +05:30
commit 8bd4e4f3bf
11 changed files with 43 additions and 11 deletions

View file

@ -45,7 +45,7 @@ class DocType():
raise webnotes.DuplicateEntryError
def on_trash(self):
if webnotes.conn.sql("""select count(*) from `tabFile Data`
if self.doc.file_name and webnotes.conn.sql("""select count(*) from `tabFile Data`
where file_name=%s""", self.doc.file_name)[0][0]==1:
path = webnotes.utils.get_path("public", "files", self.doc.file_name)
if os.path.exists(path):

View file

@ -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);
};

View file

@ -11,7 +11,8 @@ wn.form.formatters = {
parseInt(wn.boot.sysdefaults.float_precision) : null;
return "<div style='text-align: right'>" +
format_number(value, null, decimals) + "</div>";
((value==null || value==="") ? "" :
format_number(value, null, decimals)) + "</div>";
},
Int: function(value) {
return cint(value);

View file

@ -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.")
}
}
});

View file

@ -129,7 +129,8 @@ wn.views.QueryReport = Class.extend({
.css({
"display": "inline-block",
"margin-left": "5px",
"margin-bottom": "2px"
"margin-bottom": "4px",
"margin-top": "4px"
})
.attr("title", df.label).tooltip();
me.filters.push(f);

View file

@ -46,9 +46,12 @@
<p style="text-align: center" id="forgot-wrapper">
<a id="forgot-password" style="cursor:pointer"
onclick="return login.show_forgot_password()">Forgot Password</a></p>
{% if not disable_signup %}
<p style="text-align: center" id="sign-up-wrapper">
New user? <a id="sign-up" style="cursor:pointer"
onclick="return login.sign_up()">Sign Up</a></p>
{% endif %}
</div>
</div>
<div class="web-footer login-footer container">

View file

@ -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, debug=debug)
fields = fieldname
if fieldname!="*":
if isinstance(fieldname, basestring):
@ -367,6 +370,15 @@ class Database:
return r
def get_value_for_many_names(self, doctype, names, field, debug=False):
names = filter(None, names)
if names:
return dict(self.sql("select name, `%s` from `tab%s` where name in (%s)" \
% (field, doctype, ", ".join(["%s"]*len(names))), names, debug=debug))
else:
return {}
def set_value(self, dt, dn, field, val, modified=None, modified_by=None):
from webnotes.utils import now
if dn and dt!=dn:

View file

@ -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')

View file

@ -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:
@ -55,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):

View file

@ -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):

View file

@ -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 {