summaryrefslogtreecommitdiff
path: root/addons/website_customer/controllers/main.py
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2017-05-17 16:50:52 +0200
committerXavier Morel <xmo@odoo.com>2017-07-18 11:49:28 +0200
commitace4ee39e81a6da9e94236b5746f9ee70f8c9b95 (patch)
tree086ce01febb306811755745f337af3014fcb9be1 /addons/website_customer/controllers/main.py
parentdc2575b5db2aaa2c56457cbd0848a02406260ff6 (diff)
[FIX] P3: round() compatibility shim
In Python 3 round: * rounds half to even (banker's rounding) rather than up * returns an int if not given a precision (or given a precision of None) * discards the negative sign when rounding to 0 Add a compatibility shim which implements P2 behaviour and at least allows passing float_utils's tests. Implementing float_round on top of Decimal was attempted but did not work: although Decimal.quantize takes a non-integral Decimal (e.g. ``d.quantize(D('0.001'))``) it only supports integral powers of 10 and does not support quantizing to e.g. 0.05: while that will not fail it will just use the exponent for quantization and 0.05 is thus equivalent to 0.01, which is not what we want if e.g. need to round a value to 5 cents. This is hinted at but maybe not clearly spelled out by the official documentation: > Return a value equal to the first operand after rounding > and **having the exponent of** the second operand. Also convert a bunch of hand-rolled currency rounding to just using the round() method on res.currency.
Diffstat (limited to 'addons/website_customer/controllers/main.py')
0 files changed, 0 insertions, 0 deletions