Files
odoo_source/addons/web
Joseph Caburnay fead26df53 [FIX] web: more lenient monetary parser
**Issue:**

- Install CRM.
- Change language to French.
- From CRM, open a lead that has `Revenu espéré` thousands as value, e.g. 10 000,00.
- Try changing `Revenu espéré` by deleting one of the thousands digit.
  E.g. 10 000,00 -> 1 000,00
- BUG: The modified value is not understood by the system.

**Solution:**

This is because the thousands separator from the French language is nbsp.
Coincidentally, the parsing logic assumes that the separator between the
currency symbol and value is also nbsp. So when inputting `1 000,00`,
the parsers thinks either `1` or `000,00` is the currency symbol.

We concluded that it's better to be less restrictive when parsing
monetary values. So, instead of making sure that the current input's
currency is compatible with the currency of the the field, we just
strip the non-numeric characters from beginning and end of the input
without validating the currency symbol, then parse the remaining
string as float.

This leads to a more user-friendly monetary input fields such that
inputting "DOGE 1,000,000.01" in a "$" monetary field will be
parsed as 1000000.01. NOTE that *no* currency conversion is performed.

**Minor breaking change:**

The second parameter `options` of the `parseMonetary` function is now
removed. Any existing use of that parameter is just ignored.

closes odoo/odoo#107862

X-original-commit: dc27f1f4c039bdbf84c55a4fb5364c6398c45949
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
2022-12-13 17:03:25 +01:00
..
2022-10-06 14:56:52 +02:00