diff options
Diffstat (limited to 'addons/web/static/src/js/framework/utils.js')
| -rw-r--r-- | addons/web/static/src/js/framework/utils.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/web/static/src/js/framework/utils.js b/addons/web/static/src/js/framework/utils.js index 393f3766bed..a7852ce4442 100644 --- a/addons/web/static/src/js/framework/utils.js +++ b/addons/web/static/src/js/framework/utils.js @@ -292,6 +292,22 @@ function human_size (size) { } /** + * Returns a human readable number + * + * @param {Number} number + */ +function human_number (number) { + var units = _t(",k,M").split(','); + var i = 0; + while (number >= 1000) { + number /= 1000; + ++i; + } + // return number.toFixed(2) + ' ' + units[i]; + return parseInt(number) + ' ' + units[i]; +} + +/** * performs a half up rounding with arbitrary precision, correcting for float loss of precision * See the corresponding float_round() in server/tools/float_utils.py for more info * @param {Number} the value to be rounded @@ -394,6 +410,7 @@ return { is_bin_size: is_bin_size, binary_to_binsize: binary_to_binsize, human_size: human_size, + human_number: human_number, round_precision: round_precision, round_decimals: round_decimals, float_is_zero: float_is_zero, |
