Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • erp5 erp5
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Merge requests 140
    • Merge requests 140
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !2136

Merged
Created Jul 18, 2025 by Jérome Perrin@jeromeOwner

Update float rounding to be closer to python3

  • Overview 3
  • Commits 10
  • Pipelines 2
  • Changes 16

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 is ROUND_HALF_UP), the price in the xhtml_style UI and in the print invoice are rounded with '%0.2f' % f which is ROUND_HALF_EVEN and reports using mariadb with floats are rounded using ROUND_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 ) are ROUND_HALF_UP, so it feels better to abandon python2 idea of ROUND_HALF_UP and just use ROUND_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 considered "fixing" ERP5JS to also make FloatFields round with ROUND_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.
Edited Jul 29, 2025 by Jérome Perrin
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: feat/round_half_up_tmp_up
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7