Update float rounding to be closer to python3
Based on these discussions from !1881 (closed) and !1751 (merged), 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' % fwhich isROUND_HALF_EVENand 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_UPand just useROUND_HALF_EVENlike everywhere else. That said, javascript is also different here and FloatField on ERP5JS rounds differently from the same FloatField in xhtml_style. We considered "fixing" ERP5JS to also make FloatFields round withROUND_HALF_EVEN, but we did not do it in this branch, it's a totally independent problem and anyway when using json to transmit floats in javascript they get different binary representation and round differently.