Commit Graph
4 Commits
Author SHA1 Message Date
Andrea Grazioso (agr-odoo) a358096aec [FIX] web: lost sign between -1 and 0
Create a credit note for an amount between 0 and 1, confirm it.
In Accounting app, open Reporting -> Invoice Analysis
Switch to Pivot View
The credit note amount will be positive

This occur because in `insertThousandsSep` the number -0 is converted
to "0" (string), thus losing the sign before saving it

opw-2759964

closes odoo/odoo#84946

X-original-commit: c71d4c2349e623a4bcc49c2318fbbc9de08e0fa4
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
2022-02-21 10:28:28 +00:00
Xavier BOL (xbo) eb2ba319a1 [FIX] web: fix formatFloat when the value is null
Before this commit, when the value is null in the pivot view on a float
field, we format the value before displaying it. The problem is the
formatFloat method does not check if the value is null and used the
`toFixed` method to fixed the number of digits to display for the value.

This commit uses the value if it is not value otherwise use 0 to fixed
the number of digits. That is, when the value is null, the formatter
will return "0.00" (if the number of digits expected is 2) instead of
raise an error.

Steps to reproduce:
==================

1) Go to the helpdesk App > Reporting > Tickets Analysis.
2) Go to pivot view of this report.
3) Add the measure called "Rating (/5)"

Expected behaviour:
==================

Show the pivot with empty cells or 0.00 if the average of this measure
has no values.

Actual behaviour:
================

Traceback shown because it cannot read 'toFixed' property of null.

task-2665899

closes #79034

X-original-commit: d142705d9262dfa5fb489611ae0b5a2a04ff6fab
Part-of: odoo/odoo#79291
2021-11-02 16:59:55 +00:00
Lucas Perais (lpe) a19ad0fe24 [FIX] web: formatter: monetary with human number
HumanNumber now correctly rounds the number according to decimals (bug with value < 1000 eg: 0.02)
It also correctly keeps `decimals` significant figures whatever powers of 10^3 it should keep

The monetary formatter now passes the currency's digits to human number

Part-of: odoo/odoo#73311
2021-09-07 10:04:34 +00:00
Aaron Bohy 6a59d0014e [REF] web: reorganize formatters and parsers
- fields/format.js has been renamed into fields/formatters.js
 - fields/parsers.js has been introduced
 - parsers and formatters from l10n/numbers have been moved to
   fields/parsers.js and fields/formatters.js
 - same for parseCurrency and formatCurrency, and they have been
   renamed into parse/formatMonetary
 - humanReadable option is now a boolean, no longer a function
 - formatPercentage implementation has been simplified thanks to
   that reorganization
 - tests have been reorganized accordingly
2021-08-16 14:56:16 +00:00