[FIX] website: fix number comparison for form field visibility

Steps to reproduce the bug.

- In website edit mode, add a form snippet to a page.
- Add a "number" field within this form.
- Modify the label of this field in the options and name it "Field 1".
- Add a "text" field to the form.
- In the options of the "Text" field, select "Visible only if" for the
"visibility" option.
- Then, choose "Field 1" and "Is greater than" in the two dropdowns that
follow.
- Enter "10" in the input below.
- Save the page.
- Enter "2" in the "Field 1" input.
- Bug: The text field is displayed, even though it should only be
visible if "Field 1" is greater than 10.

This bug exists since the "conditionally show form fields" feature was
added to Website (in this commit [1]). The bug happened because we were
comparing strings instead of numbers.

[1]: https://github.com/odoo/odoo/commit/2dcbfecf3c10687a2cd3af36335d5be70c904fce

opw-3449900

closes odoo/odoo#133838

X-original-commit: e4d64c9f4470874ca853bd871064bb8374c8b5cc
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
Benjamin Vray
2023-08-31 17:27:51 +00:00
parent 69681447c4
commit fa8f33ced6
@@ -707,13 +707,13 @@
case '!set':
return !value;
case 'greater':
return value > comparable;
return parseFloat(value) > parseFloat(comparable);
case 'less':
return value < comparable;
return parseFloat(value) < parseFloat(comparable);
case 'greater or equal':
return value >= comparable;
return parseFloat(value) >= parseFloat(comparable);
case 'less or equal':
return value <= comparable;
return parseFloat(value) <= parseFloat(comparable);
case 'fileSet':
return value.name !== '';
case '!fileSet':