~openerp-community/openobject-doc/ksa-openobject-doc-6.0

« back to all changes in this revision

Viewing changes to i18n/ru/source/developer/2_5_Objects_Fields_Methods/openerp_fields.rst

  • Committer: Don Kirkby
  • Date: 2011-02-21 20:46:11 UTC
  • mfrom: (433.1.53 openobject-doc)
  • Revision ID: donkirkby+launpd@gmail.com-20110221204611-1ykt6dmg4k3gh5dh
[MERGE] revisions 477 to 486 from the 5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
.. i18n: .. _fields-link:
 
3
.. i18n: 
 
4
.. i18n: Fields Introduction
 
5
.. i18n: ===================
 
6
..
 
7
 
 
8
.. _fields-link:
 
9
 
 
10
Fields Introduction
 
11
===================
 
12
 
 
13
.. i18n: Objects may contain different types of fields. Those types can be divided into
 
14
.. i18n: three categories: simple types, relation types and functional fields. The
 
15
.. i18n: simple types are integers, floats, booleans, strings, etc ... ; the relation
 
16
.. i18n: types are used to represent relations between objects (one2one, one2many,
 
17
.. i18n: many2one). Functional fields are special fields because they are not stored in
 
18
.. i18n: the database but calculated in real time given other fields of the view.
 
19
..
 
20
 
 
21
Objects may contain different types of fields. Those types can be divided into
 
22
three categories: simple types, relation types and functional fields. The
 
23
simple types are integers, floats, booleans, strings, etc ... ; the relation
 
24
types are used to represent relations between objects (one2one, one2many,
 
25
many2one). Functional fields are special fields because they are not stored in
 
26
the database but calculated in real time given other fields of the view.
 
27
 
 
28
.. i18n: Here's the header of the initialization method of the class any field defined
 
29
.. i18n: in OpenERP inherits (as you can see in server/bin/osv/fields.py)::
 
30
.. i18n: 
 
31
.. i18n:     def __init__(self, string='unknown', required=False, readonly=False,
 
32
.. i18n:                  domain=None, context="", states=None, priority=0, change_default=False, size=None,
 
33
.. i18n:                  ondelete="set null", translate=False, select=False, **args) :
 
34
..
 
35
 
 
36
Here's the header of the initialization method of the class any field defined
 
37
in OpenERP inherits (as you can see in server/bin/osv/fields.py)::
 
38
 
 
39
    def __init__(self, string='unknown', required=False, readonly=False,
 
40
                 domain=None, context="", states=None, priority=0, change_default=False, size=None,
 
41
                 ondelete="set null", translate=False, select=False, **args) :
 
42
 
 
43
.. i18n: There are a common set of optional parameters that are available to most field
 
44
.. i18n: types:
 
45
..
 
46
 
 
47
There are a common set of optional parameters that are available to most field
 
48
types:
 
49
 
 
50
.. i18n: :change_default: 
 
51
.. i18n:        Whether or not the user can define default values on other fields depending 
 
52
.. i18n:        on the value of this field. Those default values need to be defined in
 
53
.. i18n:        the ir.values table.
 
54
.. i18n: :help: 
 
55
.. i18n:        A description of how the field should be used: longer and more descriptive
 
56
.. i18n:        than `string`. It will appear in a tooltip when the mouse hovers over the 
 
57
.. i18n:        field.
 
58
.. i18n: :ondelete: 
 
59
.. i18n:        How to handle deletions in a related record. Allowable values are: 
 
60
.. i18n:        'restrict', 'no action', 'cascade', 'set null', and 'set default'.
 
61
.. i18n: :priority: Not used?
 
62
.. i18n: :readonly: `True` if the user cannot edit this field, otherwise `False`.
 
63
.. i18n: :required:
 
64
.. i18n:        `True` if this field must have a value before the object can be saved, 
 
65
.. i18n:        otherwise `False`.
 
66
.. i18n: :size: The size of the field in the database: number characters or digits.
 
67
.. i18n: :states:
 
68
.. i18n:        Lets you override other parameters for specific states of this object. 
 
69
.. i18n:        Accepts a dictionary with the state names as keys and a list of name/value 
 
70
.. i18n:        tuples as the values. For example: `states={'posted':[('readonly',True)]}`
 
71
.. i18n: :string: 
 
72
.. i18n:        The field name as it should appear in a label or column header. Strings
 
73
.. i18n:        containing non-ASCII characters must use python unicode objects. 
 
74
.. i18n:        For example: `'tested': fields.boolean(u'Testé')` 
 
75
.. i18n: :translate:
 
76
.. i18n:        `True` if the *content* of this field should be translated, otherwise 
 
77
.. i18n:        `False`.
 
78
..
 
79
 
 
80
:change_default: 
 
81
        Whether or not the user can define default values on other fields depending 
 
82
        on the value of this field. Those default values need to be defined in
 
83
        the ir.values table.
 
84
:help: 
 
85
        A description of how the field should be used: longer and more descriptive
 
86
        than `string`. It will appear in a tooltip when the mouse hovers over the 
 
87
        field.
 
88
:ondelete: 
 
89
        How to handle deletions in a related record. Allowable values are: 
 
90
        'restrict', 'no action', 'cascade', 'set null', and 'set default'.
 
91
:priority: Not used?
 
92
:readonly: `True` if the user cannot edit this field, otherwise `False`.
 
93
:required:
 
94
        `True` if this field must have a value before the object can be saved, 
 
95
        otherwise `False`.
 
96
:size: The size of the field in the database: number characters or digits.
 
97
:states:
 
98
        Lets you override other parameters for specific states of this object. 
 
99
        Accepts a dictionary with the state names as keys and a list of name/value 
 
100
        tuples as the values. For example: `states={'posted':[('readonly',True)]}`
 
101
:string: 
 
102
        The field name as it should appear in a label or column header. Strings
 
103
        containing non-ASCII characters must use python unicode objects. 
 
104
        For example: `'tested': fields.boolean(u'Testé')` 
 
105
:translate:
 
106
        `True` if the *content* of this field should be translated, otherwise 
 
107
        `False`.
 
108
 
 
109
.. i18n: There are also some optional parameters that are specific to some field types:
 
110
..
 
111
 
 
112
There are also some optional parameters that are specific to some field types:
 
113
 
 
114
.. i18n: :context: 
 
115
.. i18n:        Define a variable's value visible in the view's context or an on-change 
 
116
.. i18n:        function. Used when searching child table of `one2many` relationship?
 
117
.. i18n: :domain: 
 
118
.. i18n:     Domain restriction on a relational field.
 
119
..
 
120
 
 
121
:context: 
 
122
        Define a variable's value visible in the view's context or an on-change 
 
123
        function. Used when searching child table of `one2many` relationship?
 
124
:domain: 
 
125
    Domain restriction on a relational field.
 
126
 
 
127
.. i18n:     Default value: []. 
 
128
..
 
129
 
 
130
    Default value: []. 
 
131
 
 
132
.. i18n:     Example: domain=[('field','=',value)])
 
133
.. i18n: :invisible: Hide the field's value in forms. For example, a password.
 
134
.. i18n: :on_change:
 
135
.. i18n:        Default value for the `on_change` attribute in the view. This will launch
 
136
.. i18n:        a function on the server when the field changes in the client. For example,
 
137
.. i18n:        `on_change="onchange_shop_id(shop_id)"`. 
 
138
.. i18n: :relation:
 
139
.. i18n:        Used when a field is an id reference to another table. This is the name of
 
140
.. i18n:        the table to look in. Most commonly used with related and function field
 
141
.. i18n:        types.
 
142
.. i18n: :select: 
 
143
.. i18n:        Default value for the `select` attribute in the view. 1 means basic search,
 
144
.. i18n:        and 2 means advanced search.
 
145
..
 
146
 
 
147
    Example: domain=[('field','=',value)])
 
148
:invisible: Hide the field's value in forms. For example, a password.
 
149
:on_change:
 
150
        Default value for the `on_change` attribute in the view. This will launch
 
151
        a function on the server when the field changes in the client. For example,
 
152
        `on_change="onchange_shop_id(shop_id)"`. 
 
153
:relation:
 
154
        Used when a field is an id reference to another table. This is the name of
 
155
        the table to look in. Most commonly used with related and function field
 
156
        types.
 
157
:select: 
 
158
        Default value for the `select` attribute in the view. 1 means basic search,
 
159
        and 2 means advanced search.