summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/utils.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2015-11-25 13:26:02 +0100
committerChristophe Simonis <chs@odoo.com>2015-11-25 13:26:02 +0100
commit56a442e205f7837282f3f74afd0694bfe3a64ca1 (patch)
treef964cf6899e0000202d9b7acaabe18023b2d9257 /addons/web/static/src/js/framework/utils.js
parent8d3bdf6b50382020ae3d98d8911c3a136e17d519 (diff)
parentdade7e3c1790bf54187618b0a1c4befab935dfd5 (diff)
[MERGE] forward port of branch saas-6 up to dade7e3
Diffstat (limited to 'addons/web/static/src/js/framework/utils.js')
-rw-r--r--addons/web/static/src/js/framework/utils.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/web/static/src/js/framework/utils.js b/addons/web/static/src/js/framework/utils.js
index f99d99ccc14..f1f28d83613 100644
--- a/addons/web/static/src/js/framework/utils.js
+++ b/addons/web/static/src/js/framework/utils.js
@@ -322,7 +322,16 @@ function round_precision (value, precision) {
var epsilon_magnitude = Math.log(Math.abs(normalized_value))/Math.log(2);
var epsilon = Math.pow(2, epsilon_magnitude - 53);
normalized_value += normalized_value >= 0 ? epsilon : -epsilon;
- var rounded_value = Math.round(normalized_value);
+
+ /**
+ * Javascript performs strictly the round half up method, which is asymmetric. However, in
+ * Python, the method is symmetric. For example:
+ * - In JS, Math.round(-0.5) is equal to -0.
+ * - In Python, round(-0.5) is equal to -1.
+ * We want to keep the Python behavior for consistency.
+ */
+ var sign = normalized_value < 0 ? -1.0 : 1.0;
+ var rounded_value = sign * Math.round(Math.abs(normalized_value));
return rounded_value * precision;
}