Update float rounding to be closer to python3
Based on these discussions from !1881 and !1751, we realized that:
- with ERP5 on python2, the rounding rules were already not consistent. This new test is failing on python2 current master, the accounting lines are created with
round
(that isROUND_HALF_UP
), the price in the xhtml_style UI and in the print invoice are rounded with'%0.2f' % f
which isROUND_HALF_EVEN
and reports using mariadb with floats are rounded usingROUND_HALF_EVEN
, so we already had inconsistencies and I think we only had one case recently of customer complaining about it. I thought changing round would have a major impact, now I start to believe it would probably not even be noticed, or be noticed as fixing a bug. - most of the round implementations ( python3's
round
, python2'%0.2f' % f
, mariadb ) areROUND_HALF_UP
, so it feels better to abandon python2 idea ofROUND_HALF_UP
and just useROUND_HALF_EVEN
like everywhere else. That said, javascript is also different here and FloatField on ERP5JS rounds differently from the same FloatField in xhtml_style (we can "fix" ERP5JS to also make FloatFields round withROUND_HALF_EVEN
)