~openerp-community/openobject-doc/6.1

« back to all changes in this revision

Viewing changes to i18n/vi/source/developer/2_6_views_events/events/events.rst

  • Committer: TruongSinh Tran
  • Date: 2009-07-19 19:02:35 UTC
  • Revision ID: truongsinh@vipescoserver-20090719190235-fu3bxcrbpvwuk5h7
[FIX] build_i18n.py .. raw:: html

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
The on_change attribute defines a method that is called when the content of a view field has changed.
17
17
 
18
18
.. i18n: This method takes at least arguments: cr, uid, ids, which are the three classical arguments and also the context dictionary. You can add parameters to the method. They must correspond to other fields defined in the view, and must also be defined in the XML with fields defined this way::
19
 
 
20
 
        <field name="name_of_field" on_change="name_of_method(other_field'_1_', ..., other_field'_n_')"/>.. i18n:  
21
 
 
22
 
        .. i18n: <field name="name_of_field" on_change="name_of_method(other_field'_1_', ..., other_field'_n_')"/> 
 
19
.. i18n: 
 
20
.. i18n:         <field name="name_of_field" on_change="name_of_method(other_field'_1_', ..., other_field'_n_')"/> 
 
21
 
 
22
This method takes at least arguments: cr, uid, ids, which are the three classical arguments and also the context dictionary. You can add parameters to the method. They must correspond to other fields defined in the view, and must also be defined in the XML with fields defined this way::
23
23
 
24
24
        <field name="name_of_field" on_change="name_of_method(other_field'_1_', ..., other_field'_n_')"/> 
25
25
 
28
28
The example below is from the sale order view.
29
29
 
30
30
.. i18n: You can use the 'context' keyword to access data in the context that can be used as params of the function.::
31
 
 
32
 
        <field name="shop_id" select="1" on_change="onchange_shop_id(shop_id)"/>
33
 
 
34
 
        .. i18n: <field name="shop_id" select="1" on_change="onchange_shop_id(shop_id)"/>
 
31
.. i18n: 
 
32
.. i18n:         <field name="shop_id" select="1" on_change="onchange_shop_id(shop_id)"/>
 
33
 
 
34
You can use the 'context' keyword to access data in the context that can be used as params of the function.::
35
35
 
36
36
        <field name="shop_id" select="1" on_change="onchange_shop_id(shop_id)"/>
37
37
 
38
38
.. i18n: .. code-block:: python
 
39
.. i18n: 
 
40
.. i18n:         def onchange_shop_id(self, cr, uid, ids, shop_id):
 
41
.. i18n: 
 
42
.. i18n:             v={} 
 
43
.. i18n:             if shop_id:
 
44
.. i18n: 
 
45
.. i18n:                 shop=self.pool.get('sale.shop').browse(cr,uid,shop_id) 
 
46
.. i18n:                 v['project_id']=shop.project_id.id 
 
47
.. i18n:                 if shop.pricelist_id.id:
 
48
.. i18n: 
 
49
.. i18n:                     v['pricelist_id']=shop.pricelist_id.id 
 
50
.. i18n: 
 
51
.. i18n:                 v['payment_default_id']=shop.payment_default_id.id 
 
52
.. i18n: 
 
53
.. i18n:             return {'value':v} 
 
54
 
 
55
.. code-block:: python
39
56
 
40
57
        def onchange_shop_id(self, cr, uid, ids, shop_id):
41
58
 
42
 
        .. i18n: def onchange_shop_id(self, cr, uid, ids, shop_id):
43
 
 
44
59
            v={} 
45
60
            if shop_id:
46
61
 
47
 
            .. i18n: v={} 
48
 
            .. i18n: if shop_id:
49
 
 
50
62
                shop=self.pool.get('sale.shop').browse(cr,uid,shop_id) 
51
63
                v['project_id']=shop.project_id.id 
52
64
                if shop.pricelist_id.id:
53
65
 
54
 
                .. i18n: shop=self.pool.get('sale.shop').browse(cr,uid,shop_id) 
55
 
                .. i18n: v['project_id']=shop.project_id.id 
56
 
                .. i18n: if shop.pricelist_id.id:
57
 
 
58
66
                    v['pricelist_id']=shop.pricelist_id.id 
59
67
 
60
 
                    .. i18n: v['pricelist_id']=shop.pricelist_id.id 
61
 
 
62
68
                v['payment_default_id']=shop.payment_default_id.id 
63
69
 
64
 
                .. i18n: v['payment_default_id']=shop.payment_default_id.id 
65
 
 
66
 
            return {'value':v}.. i18n:  
67
 
 
68
 
            .. i18n: return {'value':v} 
69
 
 
70
70
            return {'value':v} 
71
71
 
72
72
.. i18n: When editing the shop_id form field, the onchange_shop_id method of the sale_order object is called and returns a dictionary where the 'value' key contains a dictionary of the new value to use in the 'project_id', 'pricelist_id' and 'payment_default_id' fields.
86
86
See the example below:
87
87
 
88
88
.. i18n: .. code-block:: xml
89
 
 
90
 
        <record model="ir.actions.act_window" id="a">
91
 
            <field name="name">account.account.tree1</field> 
92
 
            <field name="res_model">account.account</field> 
93
 
            <field name="view_type">tree</field> 
94
 
            <field name="view_mode">form,tree</field> 
95
 
            <field name="view_id" ref="v"/> 
96
 
            <field name="domain">[('code','=','0')]</field> 
97
 
            <field name="context">{'project_id': active_id}</field> 
98
 
        </record>
99
 
 
100
 
        .. i18n: <record model="ir.actions.act_window" id="a">
101
 
            .. i18n: <field name="name">account.account.tree1</field> 
102
 
            .. i18n: <field name="res_model">account.account</field> 
103
 
            .. i18n: <field name="view_type">tree</field> 
104
 
            .. i18n: <field name="view_mode">form,tree</field> 
105
 
            .. i18n: <field name="view_id" ref="v"/> 
106
 
            .. i18n: <field name="domain">[('code','=','0')]</field> 
107
 
            .. i18n: <field name="context">{'project_id': active_id}</field> 
108
 
        .. i18n: </record>
 
89
.. i18n: 
 
90
.. i18n:         <record model="ir.actions.act_window" id="a">
 
91
.. i18n:             <field name="name">account.account.tree1</field> 
 
92
.. i18n:             <field name="res_model">account.account</field> 
 
93
.. i18n:             <field name="view_type">tree</field> 
 
94
.. i18n:             <field name="view_mode">form,tree</field> 
 
95
.. i18n:             <field name="view_id" ref="v"/> 
 
96
.. i18n:             <field name="domain">[('code','=','0')]</field> 
 
97
.. i18n:             <field name="context">{'project_id': active_id}</field> 
 
98
.. i18n:         </record>
 
99
 
 
100
.. code-block:: xml
109
101
 
110
102
        <record model="ir.actions.act_window" id="a">
111
103
            <field name="name">account.account.tree1</field> 
118
110
        </record>
119
111
 
120
112
.. i18n: view_type::
121
 
 
122
 
        tree = (tree with shortcuts at the left), form = (switchaable view form/list).. i18n:  
123
 
 
124
 
        .. i18n: tree = (tree with shortcuts at the left), form = (switchaable view form/list) 
 
113
.. i18n: 
 
114
.. i18n:         tree = (tree with shortcuts at the left), form = (switchaable view form/list) 
 
115
 
 
116
view_type::
125
117
 
126
118
        tree = (tree with shortcuts at the left), form = (switchaable view form/list) 
127
119
 
128
120
.. i18n: view_mode::
129
 
 
130
 
        tree,form : sequences of the views when switching.. i18n:  
131
 
 
132
 
        .. i18n: tree,form : sequences of the views when switching 
 
121
.. i18n: 
 
122
.. i18n:         tree,form : sequences of the views when switching 
 
123
 
 
124
view_mode::
133
125
 
134
126
        tree,form : sequences of the views when switching 
135
127
 
145
137
 
146
138
.. i18n: Get back the value by default for one or several fields. 
147
139
 
148
 
Get back the value by default for one or several fields... i18n:  
 
140
Get back the value by default for one or several fields. 
149
141
 
150
 
    .. i18n: **Signature:** def default_get(self, cr, uid, fields, form=None, reference=None) 
151
 
    .. i18n: 
152
 
    .. i18n: **Parameters:**
 
142
.. i18n:     **Signature:** def default_get(self, cr, uid, fields, form=None, reference=None) 
 
143
.. i18n:     
 
144
.. i18n:     **Parameters:**
153
145
 
154
146
    **Signature:** def default_get(self, cr, uid, fields, form=None, reference=None) 
155
147
    
156
148
    **Parameters:**
157
149
 
158
 
            .. i18n: * fields: the fields list which we want to recover the value by default.
159
 
            .. i18n: * form (optional): TODO
160
 
            .. i18n: * reference (optional): TODO 
 
150
.. i18n:             * fields: the fields list which we want to recover the value by default.
 
151
.. i18n:             * form (optional): TODO
 
152
.. i18n:             * reference (optional): TODO 
161
153
 
162
154
            * fields: the fields list which we want to recover the value by default.
163
155
            * form (optional): TODO
164
 
            * reference (optional): TODO.. i18n:  
165
 
 
166
 
    .. i18n: **Returns:** dictionary of the default values of the form {'field_name': value, ... } 
167
 
 
168
 
    **Returns:** dictionary of the default values of the form {'field_name': value, ... }.. i18n:  
 
156
            * reference (optional): TODO 
 
157
 
 
158
.. i18n:     **Returns:** dictionary of the default values of the form {'field_name': value, ... } 
 
159
 
 
160
    **Returns:** dictionary of the default values of the form {'field_name': value, ... } 
169
161
 
170
162
.. i18n: Example::
171
 
 
172
 
        TODO
173
 
 
174
 
        .. i18n: self.pool.get('hr.analytic.timesheet').default_get(cr, uid, ['product_id','product_uom_id'])
 
163
.. i18n: 
 
164
.. i18n:         self.pool.get('hr.analytic.timesheet').default_get(cr, uid, ['product_id','product_uom_id'])
 
165
 
 
166
Example::
175
167
 
176
168
        self.pool.get('hr.analytic.timesheet').default_get(cr, uid, ['product_id','product_uom_id'])
177
169
 
187
179
 
188
180
Change the default value for one or several fields.
189
181
 
190
 
    .. i18n: **Signature:** def default_set(self, cr, uid, field, value, for_user=False) 
191
 
    .. i18n: 
192
 
    .. i18n: **Parameters:**
 
182
.. i18n:     **Signature:** def default_set(self, cr, uid, field, value, for_user=False) 
 
183
.. i18n:     
 
184
.. i18n:     **Parameters:**
193
185
 
194
186
    **Signature:** def default_set(self, cr, uid, field, value, for_user=False) 
195
187
    
196
188
    **Parameters:**
197
189
 
198
 
            .. i18n: * field: the name of the field that we want to change the value by default.
199
 
            .. i18n: * value: the value by default.
200
 
            .. i18n: * for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users. 
 
190
.. i18n:             * field: the name of the field that we want to change the value by default.
 
191
.. i18n:             * value: the value by default.
 
192
.. i18n:             * for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users. 
201
193
 
202
194
            * field: the name of the field that we want to change the value by default.
203
195
            * value: the value by default.
204
 
            * for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users... i18n:  
205
 
 
206
 
    .. i18n: **Returns:** True 
207
 
 
208
 
    **Returns:** True.. i18n:  
 
196
            * for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users. 
 
197
 
 
198
.. i18n:     **Returns:** True 
 
199
 
 
200
    **Returns:** True 
209
201
 
210
202
.. i18n: Example::
211
 
 
212
 
        TODO
213
 
 
214
 
        .. i18n: TODO
 
203
.. i18n: 
 
204
.. i18n:         TODO
 
205
 
 
206
Example::
215
207
 
216
208
        TODO