tolerate non-float values when displaying decimal field
This commit is contained in:
parent
6336567674
commit
0ca62ba27e
1 changed files with 6 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2011 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2012 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -273,6 +273,10 @@ class DecimalFieldInstance(NumberFieldInstance):
|
||||||
def display(self, value, pattern=u'#,##0.00;-#,##0.00'):
|
def display(self, value, pattern=u'#,##0.00;-#,##0.00'):
|
||||||
if value is None:
|
if value is None:
|
||||||
return ''
|
return ''
|
||||||
|
if isinstance(value, basestring):
|
||||||
|
if not value.isdigit():
|
||||||
|
return value
|
||||||
|
value = float(value)
|
||||||
view = self.clientInstance.view
|
view = self.clientInstance.view
|
||||||
langInfo = view and getattr(view, 'languageInfo', None) or None
|
langInfo = view and getattr(view, 'languageInfo', None) or None
|
||||||
if langInfo:
|
if langInfo:
|
||||||
|
@ -292,7 +296,7 @@ class DecimalFieldInstance(NumberFieldInstance):
|
||||||
class DateFieldInstance(NumberFieldInstance):
|
class DateFieldInstance(NumberFieldInstance):
|
||||||
|
|
||||||
def marshall(self, value):
|
def marshall(self, value):
|
||||||
if value is None:
|
if not value:
|
||||||
return ''
|
return ''
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
return value
|
return value
|
||||||
|
|
Loading…
Add table
Reference in a new issue