From 0b6219a5b4928cff335bd8695aa55e63d9f29e80 Mon Sep 17 00:00:00 2001 From: "Anh Thao Pham (pta)" Date: Mon, 19 Oct 2020 14:37:46 +0000 Subject: [PATCH] [FIX] point_of_sale: fix decimals converted into units after parse In a POS session, in a language that does not use dot (.) as decimal separator (i.e. French), when adding a Product, it can happen that the decimal part of the price is not converted correctly after applying "field_utils.parse.float". (i.e. 2.69 becomes 269) The issue happens in "set_unit_price" function. To prevent this to happen, "field_utils.parse.float" will only be applied if the price given as parameter is not a number. opw-2357848 closes odoo/odoo#60344 X-original-commit: 7687732a8a2e1afe87272fc31ccd4437ed9a8db1 Signed-off-by: Anh Thao PHAM --- addons/point_of_sale/static/src/js/models.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 04b834e7e0b..8c5254946d5 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1924,7 +1924,9 @@ exports.Orderline = Backbone.Model.extend({ // changes the base price of the product for this orderline set_unit_price: function(price){ this.order.assert_editable(); - var parsed_price = isNaN(parseFloat(price)) ? 0 : field_utils.parse.float('' + price) + var parsed_price = !isNaN(price) ? + price : + isNaN(parseFloat(price)) ? 0 : field_utils.parse.float('' + price) this.price = round_di(parsed_price || 0, this.pos.dp['Product Price']); this.trigger('change',this); },