From dda904c13392473c0e213078cbb6fc73374a96a0 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Mon, 29 Feb 2016 15:00:32 +0100 Subject: [PATCH] [FIX] point_of_sale: avoid '.' thousands separator issues When we render the payment screen the current value of the current paymentline is rendered to a string using Paymentline.get_amount_str(). This conversion always rendered numbers with a decimal separator of '.' because it just used Number.toFixed(). This used to be fine but 5a10903e9b3b3f8143a8f8d3703632e3243efead made the POS adhere to the set decimal and thousands separator. Because of this, the POS now has to parse the input with web.parse_value() which takes into account these separators. When parse_value() parses a float it first deletes the thousands separators and then replaces the decimal separator with '.' before it gets cast to a Number. In German (and other languages), the '.' is used as a thousands separator which means that it will get deleted by parse_value() so you'll end up with '12.34' being interpreted as '1234'. Because of this it is important that we ensure that the default value that appears in the input uses the correct separators. The aforementioned issue only occurs when the user changes the default value in the paymentline. Only then does a conversion take place from String to Number. So just clicking on a payment method of type 'Bank' and validating it would work fine, only when the payment amount was updated would the issue occur. Fixes #9395 Closes #10952 note: this should not be forward-ported to >8.0 because later versions use the rewritten payment screen which is completely different from the one in 8.0. --- 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 6041ba2910f..4f753ffcb6e 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -972,7 +972,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal return this.amount; }, get_amount_str: function(){ - return this.amount.toFixed(this.pos.currency.decimals); + return openerp.instances[this.pos.session.name].web.format_value(this.amount, { + type: 'float', digits: [69, this.pos.currency.decimals] + }); }, set_selected: function(selected){ if(this.selected !== selected){