Merge branch 'master' of github.com:webnotes/wnframework

This commit is contained in:
Rushabh Mehta 2013-03-01 18:26:17 +05:30
commit 6a0ecde1e7
8 changed files with 40 additions and 17 deletions

View file

@ -94,7 +94,7 @@ cur_frm.cscript.hide_allow_attach = function(doc, dt, dn) {
'Leave Application', 'Lead', 'Journal Voucher', 'Item', 'Material Request',
'Expense Claim', 'Opportunity', 'Employee', 'Delivery Note',
'Customer Issue', 'Customer', 'Contact Us Settings', 'Company',
'Blog', 'BOM', 'About Us Settings'];
'Blog', 'BOM', 'About Us Settings', 'Batch'];
if(inList(allow_attach_list, doc.doc_type)) {
unhide_field('allow_attach');

View file

@ -129,7 +129,7 @@ def get_template():
webnotes.response['doctype'] = doctype
def getdocfield(fieldname):
"""get docfield from doclist of doctype"""
"""get docfield from doclist of doctype"""
l = [d for d in doctype_dl if d.doctype=='DocField' and d.fieldname==fieldname]
return l and l[0] or None
@ -256,6 +256,10 @@ def check_record(d, parenttype):
if parenttype and not d.get('parent'):
raise Exception, "parent is required."
global doctype_dl
if not doctype_dl:
doctype_dl = webnotes.model.doctype.get(d.doctype)
for key in d:
docfield = getdocfield(key)
val = d[key]

View file

@ -107,7 +107,7 @@ function flt(v, decimals) {
}
// strip groups (,)
if(wn.number_format_info.group_sep==".") {
if(get_number_format_info(get_number_format()).group_sep==".") {
v = v.replace(/\./g,'');
// sanitize decimal separator to .

View file

@ -793,7 +793,9 @@ _f.Frm.prototype.runclientscript = function(caller, cdt, cdn) {
} catch(e) {
validated = false;
console.log(e);
// show error message
this.log_error(caller, e);
}
if(caller && caller.toLowerCase()=='setup') {
this.setup_client_js();
@ -810,8 +812,8 @@ _f.Frm.prototype.setup_client_js = function(caller, cdt, cdn) {
try {
var tmp = eval(cs);
} catch(e) {
show_alert("Error in Client Script.")
console.log(e);
show_alert("Error in Client Script.");
this.log_error(caller || "setup_client_js", e);
}
}
@ -828,6 +830,17 @@ _f.Frm.prototype.setup_client_js = function(caller, cdt, cdn) {
}
}
_f.Frm.prototype.log_error = function(caller, e) {
console.group && console.group();
console.log("----- error in client script -----");
console.log("method: " + caller);
console.log(e);
console.log("error message: " + e.message);
console.trace && console.trace();
console.log("----- end of error message -----");
console.group && console.groupEnd();
}
_f.Frm.prototype.copy_doc = function(onload, from_amend) {
if(!this.perm[0][CREATE]) {
msgprint('You are not allowed to create '+this.meta.name);

View file

@ -104,7 +104,7 @@ wn.Application = Class.extend({
},
make_page_container: function() {
if($("#body_div").length) {
wn.temp_container = $("<div id='#temp-container' style='display: none;'>")
wn.temp_container = $("<div id='temp-container' style='display: none;'>")
.appendTo("body");
wn.container = new wn.views.Container();
}

View file

@ -12,14 +12,10 @@ wn.number_format_info = {
}
window.format_number = function(v, format, decimals){
if (!format) {
format = get_number_format();
}
var info = wn.number_format_info[format];
if(!info) {
info = {decimal_str:".", group_sep:",", precision:2};
}
info = get_number_format_info(format);
if(isNaN(+v) || v==null) {
v=0;
@ -105,4 +101,12 @@ function get_number_format() {
|| "#,###.##";
}
return global_number_format;
}
function get_number_format_info(format) {
var info = wn.number_format_info[format];
if(!info) {
info = {decimal_str:".", group_sep:",", precision:2};
}
return info;
}

View file

@ -97,14 +97,14 @@ class IncomingMail:
})
def save_attachments_in_doc(self, doc):
from webnotes.utils.file_manager import save_file, add_file_list
from webnotes.utils.file_manager import save_file, add_file_list, MaxFileSizeReachedError
for attachment in self.attachments:
try:
fid = save_file(attachment['filename'], attachment['content'])
status = add_file_list(doc.doctype, doc.name, fid, fid)
except:
from webnotes.utils.scheduler import log
log("receive.set_attachments_in_doc")
except MaxFileSizeReachedError:
# bypass max file size exception
pass
def get_thread_id(self):
import re

View file

@ -25,6 +25,8 @@ import webnotes
import os, conf
from webnotes.utils import cstr
class MaxFileSizeReachedError(webnotes.ValidationError): pass
def upload():
# get record details
dt = webnotes.form_dict.doctype
@ -135,7 +137,7 @@ def check_max_file_size(content):
max_file_size = getattr(conf, 'max_file_size', 1000000)
if len(content) > max_file_size:
raise Exception, 'Maximum File Limit (%s MB) Crossed' % (int(max_file_size / 1000000))
raise Exception, MaxFileSizeReachedError
def write_file(content):
"""write file to disk with a random name (to compare)"""