[ADD] parsing of locale-formatted floats
bzr revid: xmo@openerp.com-20131022085450-mhymubsywkonepjx
This commit is contained in:
parent
730d0c69fe
commit
1687668026
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue