Display numbers in reports with only significant decimals

Hi,

I’m working on a Tryton report and I want to display numbers with only the significant decimals, removing unnecessary trailing zeros.

For example, a field stored in Tryton with 4 decimals as:

  • 1.2000 → REPORT: 1.2

  • 1.0000 → REPORT: 1

  • 1.2134 → REPORT: 1.2134

Does anyone see potential problems with normalizing values this way in reports? Any side effects I should be aware of?

Thanks!

It sounds like you want the same as what was done with Format float and computed Decimal using fixed-point notation (fccb90d0a3f4) · Commits · Tryton / Tryton · GitLab

Yes, thanks! That’s exactly what I was looking for.
Although, I think I’ll use this for quantities, since besides showing only the significant decimals, it also formats the number according to the customer’s language:
format_number(line.quantity, invoice.party.lang)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.