1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import ModelSQL, fields
from trytond.pool import Pool
from trytond.pyson import Eval
class Float(ModelSQL):
'Float'
__name__ = 'test.float'
float = fields.Float(string='Float', help='Test float',
required=False)
class FloatDefault(ModelSQL):
'Float Default'
__name__ = 'test.float_default'
float = fields.Float(string='Float', help='Test float',
required=False)
@staticmethod
def default_float():
return 5.5
class FloatRequired(ModelSQL):
'Float Required'
__name__ = 'test.float_required'
float = fields.Float(string='Float', help='Test float',
required=True)
class FloatDigits(ModelSQL):
'Float Digits'
__name__ = 'test.float_digits'
digits = fields.Integer('Digits')
float = fields.Float(string='Float', help='Test float',
required=False, digits=(16, Eval('digits', 2)),
depends=['digits'])
def register(module):
Pool.register(
Float,
FloatDefault,
FloatRequired,
FloatDigits,
module=module, type_='model')
|