[ADD] parsing of locale-formatted floats

bzr revid: xmo@openerp.com-20131022085450-mhymubsywkonepjx
This commit is contained in:
Xavier Morel 2013-10-22 10:54:50 +02:00
parent 730d0c69fe
commit 1687668026
2 changed files with 8 additions and 1 deletions

View File

@ -67,7 +67,13 @@ class Float(orm.AbstractModel):
_name = 'website.qweb.field.float'
_inherit = ['website.qweb.field', 'ir.qweb.field.float']
value_from_string = float
def from_html(self, cr, uid, model, column, element, context=None):
lang = self.user_lang(cr, uid, context=context)
value = element.text_content().strip()
return float(value.replace(lang.thousands_sep, '')
.replace(lang.decimal_point, '.'))
class Date(orm.AbstractModel):
_name = 'website.qweb.field.date'

View File

@ -53,6 +53,7 @@ class TestConvertBack(common.TransactionCase):
def test_float(self):
self.field_roundtrip('float', 42.567890)
self.field_roundtrip('float', 324542.567890)
def test_numeric(self):
self.field_roundtrip('numeric', 42.77)