Files
tryton/trytond/model/fields/selection.py
T

36 lines
1.5 KiB
Python
Raw Normal View History

2009-02-03 18:58:25 +01:00
#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.fields.field import Field
class Selection(Field):
2009-03-01 13:37:31 +01:00
'''
2009-09-13 15:37:11 +02:00
Define a selection field (``str``).
2009-03-01 13:37:31 +01:00
'''
2009-02-03 18:58:25 +01:00
_type = 'selection'
2009-03-01 13:37:31 +01:00
def __init__(self, selection, string='', sort=True, translate=True,
help='', required=False, readonly=False, domain=None, states=None,
2011-01-03 12:39:29 +01:00
change_default=False, select=0, on_change=None,
2011-01-07 10:58:43 +01:00
on_change_with=None, depends=None, order_field=None, context=None,
loading='eager'):
2009-03-01 13:37:31 +01:00
'''
:param selection: A list or a function name that returns a list.
2009-09-13 15:37:11 +02:00
The list must be a list of tuples. First member is the value
2009-03-01 13:37:31 +01:00
to store and the second is the value to display.
:param sort: A boolean to sort or not the selections.
'''
super(Selection, self).__init__(string=string, help=help,
required=required, readonly=readonly, domain=domain,
2011-01-03 12:39:29 +01:00
states=states, change_default=change_default, select=select,
on_change=on_change, on_change_with=on_change_with,
2011-01-07 10:58:43 +01:00
depends=depends, order_field=order_field, context=context,
loading=loading)
if hasattr(selection, 'copy'):
self.selection = selection.copy()
else:
self.selection = selection
2009-02-03 18:58:25 +01:00
self.sort = sort
self.translate_selection = translate
2009-03-01 13:37:31 +01:00
__init__.__doc__ += Field.__init__.__doc__