[FW][FIX] sale: correct discount values

When manually setting a discount on the first line of a sale order having more than 3 displayed lines, the product_discount_field widget prompts the user if he would like to apply the same discount to all the lines. 
This fails to apply when the localization uses a comma as decimal separator instead of a dot or uses a digit grouping symbol. This is because the widget calls the JS function Number() on the string that was entered by the user in the discount field, after it was formatted according to the localization.

Taking the number 1500 as an example, different cases are:
- Number("1500.0") gives 1500
- Number("1500,0") gives 'NaN'
- Number("1,500.0") gives 'NaN'
- Number("1.500,0") gives 'NaN' 

This result is then used to apply the discount on the remaining lines of the sale orders. Using 'NaN' will result in a 0% discount.

The use of Number() can be avoided by using the property field 'value' of the product_discount_field widget.

opw-3127690

closes odoo/odoo#112734

Forward-port-of: odoo/odoo#112692
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
HuylenbroeckFlorent
2023-02-16 11:35:47 +01:00
parent 1439299e2e
commit 7072c9e7e4
@@ -37,7 +37,7 @@ export class ProductDiscountField extends FloatField {
return {
operation: "UPDATE",
record: line,
data: {["discount"]: Number(ev.target.value)},
data: {["discount"]: Number(this.props.value)},
};
});