Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5 erp5
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Labels
    • Labels
  • Merge requests 140
    • Merge requests 140
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Jobs
  • Commits
Collapse sidebar
  • nexedi
  • erp5erp5
  • Merge requests
  • !2136

Open
Created Jul 18, 2025 by Jérome Perrin@jeromeOwner
  • Report abuse
Report abuse

Update float rounding to be closer to python3

  • Overview 0
  • Commits 12
  • Pipelines 2
  • Changes 27

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 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 can "fix" ERP5JS to also make FloatFields round with ROUND_HALF_EVEN)
Edited Jul 18, 2025 by Jérome Perrin
Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: feat/round_half_up_tmp_up
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7