瀏覽代碼

[utils] added a method to sum an array of numbers

version-14
Anand Doshi 12 年之前
父節點
當前提交
fb413661c2
共有 2 個檔案被更改,包括 6 行新增2 行删除
  1. +4
    -0
      public/js/wn/misc/utils.js
  2. +2
    -2
      webnotes/model/controller.py

+ 4
- 0
public/js/wn/misc/utils.js 查看文件

@@ -168,4 +168,8 @@ wn.utils = {
} }
return arr; return arr;
}, },
sum: function(list) {
return list.reduce(function(previous_value, current_value) { return flt(previous_value) + flt(current_value); });
},
}; };

+ 2
- 2
webnotes/model/controller.py 查看文件

@@ -26,7 +26,7 @@ from webnotes import msgprint, _
from webnotes.utils import flt, cint, cstr from webnotes.utils import flt, cint, cstr
from webnotes.model.meta import get_field_precision from webnotes.model.meta import get_field_precision


error_coniditon_map = {
error_condition_map = {
"=": "!=", "=": "!=",
"!=": "=", "!=": "=",
"<": ">=", "<": ">=",
@@ -71,7 +71,7 @@ class DocListController(object):
msg += _("Row") + (" # %d: " % doc.idx) msg += _("Row") + (" # %d: " % doc.idx)
msg += _(self.meta.get_label(fieldname, parent=doc.doctype)) \ msg += _(self.meta.get_label(fieldname, parent=doc.doctype)) \
+ " " + error_coniditon_map.get(condition, "") + " " + cstr(val2)
+ " " + error_condition_map.get(condition, "") + " " + cstr(val2)
# raise passed exception or True # raise passed exception or True
msgprint(msg, raise_exception=raise_exception or True) msgprint(msg, raise_exception=raise_exception or True)


Loading…
取消
儲存