[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
5a10903e9b 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.
This commit is contained in:
Joren Van Onder 2016-02-29 15:00:32 +01:00
parent f994be0e85
commit dda904c133
1 changed files with 3 additions and 1 deletions

View File

@ -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){