From 7072c9e7e45c17db65feed9227e59f946df86ded Mon Sep 17 00:00:00 2001 From: HuylenbroeckFlorent Date: Thu, 16 Feb 2023 11:35:47 +0100 Subject: [PATCH] [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) --- addons/sale/static/src/js/product_discount_field.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/static/src/js/product_discount_field.js b/addons/sale/static/src/js/product_discount_field.js index 4ccc1823f31..72761573e5c 100644 --- a/addons/sale/static/src/js/product_discount_field.js +++ b/addons/sale/static/src/js/product_discount_field.js @@ -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)}, }; });