Merge lp:~syleam/vim-openerp/many_improvements_in_snippets into lp:vim-openerp

Proposed by Sylvain Garancher
Status: Merged
Merged at revision: 99
Proposed branch: lp:~syleam/vim-openerp/many_improvements_in_snippets
Merge into: lp:vim-openerp
Diff against target: 277 lines (+88/-50)
2 files modified
vim/snippets/python.snippets (+53/-44)
vim/snippets/xml.snippets (+35/-6)
To merge this branch: bzr merge lp:~syleam/vim-openerp/many_improvements_in_snippets
Reviewer Review Type Date Requested Status
Christophe CHAUVET Approve
Review via email: mp+86722@code.launchpad.net

Description of the change

Added in Python :
- help attribute for fields
- logger methods (debug, info, warning, error)

Added in XML :
- most used gtk icons
- some useful widgets for views (url, progressbar, etc.)

Fixed the ir.values declaration for osv_memory toolbar wizards

To post a comment you must log in.
Revision history for this message
Christophe CHAUVET (christophe-chauvet) wrote :

ok

review: Approve
99. By Christophe CHAUVET

[MERGE] Merge improvement from Sylvain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'vim/snippets/python.snippets'
2--- vim/snippets/python.snippets 2011-12-19 16:07:41 +0000
3+++ vim/snippets/python.snippets 2011-12-22 15:30:41 +0000
4@@ -99,66 +99,67 @@
5 # Define type of fields
6 #
7 snippet fields fields.char
8- '${1:fieldname}': fields.char('${2:Label}', size=${3:64}, ${4}),
9+ '${1:fieldname}': fields.char('${2:Label}', size=${3:64}, ${5}help='${4:Help note}'),${6}
10 snippet fields fields.integer
11- '${1:fieldname}': fields.integer('${2:Label}', ${3}),
12+ '${1:fieldname}': fields.integer('${2:Label}', ${4}help='${3:Help note}'),${5}
13 snippet fields fields.float
14- '${1:fieldname}': fields.float('${2:Label}', ${3}),
15+ '${1:fieldname}': fields.float('${2:Label}', ${4}help='${3:Help note}'),${5}
16 snippet fields fields.boolean
17- '${1:fieldname}': fields.boolean('${2:Label}', ${3}),
18+ '${1:fieldname}': fields.boolean('${2:Label}', ${4}help='${3:Help note}'),${5}
19 snippet fields fields.date
20- '${1:fieldname}': fields.date('${2:Label}', ${3}),
21+ '${1:fieldname}': fields.date('${2:Label}', ${4}help='${3:Help note}'),${5}
22 snippet fields fields.datetime
23- '${1:fieldname}': fields.datetime('${2:Label}', ${3}),
24+ '${1:fieldname}': fields.datetime('${2:Label}', ${4}help='${3:Help note}'),${5}
25 snippet fields fields.selection
26- '${1:fieldname}': fields.selection(${2:[('','')]}, '${3:Label}', ${4}),
27+ '${1:fieldname}': fields.selection(${2:[('', '')]}, '${3:Label}', ${5}help='${4:Help note}'),${6}
28 snippet fields fields.many2one
29- '${1:fieldname}_id': fields.many2one('${2:ObjectName}', '${3:Label}', ${4}),
30+ '${1:fieldname}_id': fields.many2one('${2:ObjectName}', '${3:Label}', ${5}help='${4:Help note}'),${6}
31 snippet fields fields.many2many
32- '${1:fieldname}_ids': fields.many2many('${2:ObjectName}', '${3:TableRel}', '${4:src_id}', '${5:dst_id}', '${6:Label}', ${7}),
33+ '${1:fieldname}_ids': fields.many2many('${2:ObjectName}', '${3:TableRel}', '${4:src_id}', '${5:dst_id}', '${6:Label}', ${8}help='${7:Help note}'),${9}
34 snippet fields fields.one2many
35- '${1:fieldname}_ids': fields.one2many('${2:ObjectName}', '${3:fieldname}_id', '${4:Label}', ${5}),
36+ '${1:fieldname}_ids': fields.one2many('${2:ObjectName}', '${3:fieldname}_id', '${4:Label}', ${6}help='${5:Help note}'),${7}
37 snippet fields fields.function
38 '${1:fieldname}': fields.function(${2:FunctionName},
39 method=${3:True},
40 string='${4:label}',
41 type='${5:float}',
42- store=${6:False}, ${7}),
43+ store=${6:False},${8}
44+ help='${7:Help note}'),${9}
45 snippet fields fields.related
46- '${1:fieldname}': fields.related('${2:field in}', '${3:field rel}', type='${4:many2one}', ${5:relation='res.partner'},
47- string='${6:Label}', ${7}),
48+ '${1:fieldname}': fields.related('${2:field in}', '${3:field rel}', type='${4:many2one}', ${5:relation='res.partner'},
49+ string='${6:Label}', ${8}help='${7:Help note}'),${9}
50 snippet fields fields.property
51- '${1:fieldname}': fields.property('${2:object}', method=${3:True},
52- string='${4:label}', type='${5:many2one}', ${6}),
53+ '${1:fieldname}': fields.property('${2:object}', method=${3:True},
54+ string='${4:label}', type='${5:many2one}', ${7}help='${6:Help note}'),${8}
55 snippet fields fields.text
56- '${1:fieldname}': fields.text('${2:Label}', ${4}),
57+ '${1:fieldname}': fields.text('${2:Label}', ${4}help='${3:Help note}'),${5}
58 snippet fields fields.binary
59- '${1:fieldname}': fields.binary('${2:Label}', ${4}),
60+ '${1:fieldname}': fields.binary('${2:Label}', ${4}help='${3:Help note}'),${5}
61 snippet fields fields.reference
62- '${1:fieldname}': fields.reference('${2:Label}',selection=${3:[('','')]}, size=128, ${4}),
63+ '${1:fieldname}': fields.reference('${2:Label}', selection=${3:[('', '')]}, size=128, ${5}help='${4:Help note}'),${6}
64 # Attribute for fields
65 snippet domain
66- domain=[('${1:state}','${2:=}','${3:done}')]
67+ domain=[('${1:state}', '${2:=}', '${3:done}')]
68 snippet help
69 help='${1:Help about Field}',
70 snippet readonly
71- readonly=True,
72+ readonly=True, ${1}
73 snippet required
74- required=True,
75+ required=True, ${1}
76 snippet translate
77- translate=True,
78+ translate=True, ${1}
79 snippet select
80- select=True,
81+ select=True, ${1}
82 snippet ondel OnDelete Cascade
83- ondelete='cascade',
84+ ondelete='cascade', ${1}
85 snippet ondel OnDelete Set Null
86- ondelete='set null'
87+ ondelete='set null', ${1}
88 snippet ondelete OnDelete Cascade
89- ondelete='cascade',
90+ ondelete='cascade', ${1}
91 snippet ondelete OnDelete Set Null
92- ondelete='set null'
93+ ondelete='set null', ${1}
94 snippet store
95- store=True,
96+ store=True, ${1}
97 #
98 # Define function in osv.osv
99 #
100@@ -263,7 +264,7 @@
101 cr.execute("""CREATE OR REPLACE VIEW ${1:View} AS (
102 ${3:SELECT...})
103 """)
104- ${2}
105+ ${4}
106 snippet func def _name_get
107 def name_get(self, cr, uid, ids, context=None):
108 """
109@@ -286,7 +287,7 @@
110 def name_search(self, cr, uid, name, args=None, operator='ilike', context=None, limit=80):
111 """
112 #TODO make doc string
113- ${2:Comment this}
114+ ${1:Comment this}
115 """
116 #TODO: make a search on specific fields and get ids
117 if args is None:
118@@ -295,18 +296,18 @@
119 context = {}
120 ids = []
121 if name:
122- ids = self.search(cr, uid, [('code','ilike',name)]+ args, limit=limit)
123+ ids = self.search(cr, uid, [('code', 'ilike', name)] + args, limit=limit)
124 if not ids:
125- ids = self.search(cr, uid, [('name',operator,name)]+ args, limit=limit)
126+ ids = self.search(cr, uid, [('name', operator, name)] + args, limit=limit)
127 return self.name_get(cr, uid, ids, context=context)
128- ${3}
129+ ${2}
130 snippet func on_change
131 def onchange_${1:fields}(self, cr, uid, ids, $1, context=None):
132 """
133 #TODO make doc string
134 ${2:Comment this/compute new values from the db/system}
135 """
136- #TODO : compute new values from the db/system
137+ #TODO : compute new values from the db/system
138 if context is None:
139 context = {}
140 ${3}
141@@ -350,19 +351,19 @@
142 ## Common method define in osv.osv
143 ##
144 snippet read
145- self.read(cr, uid, ids, ['${1:field}'], context=context)
146+ self.read(cr, uid, ${1:ids}, ['${2:field}'], context=context)${3}
147 snippet browse
148- self.browse(cr, uid, ids, context=context)
149+ self.browse(cr, uid, ${1:ids}, context=context)${2}
150 snippet search
151- self.search(cr, uid, [('${1:state}','${2:=}','${3:done}')], context=context)
152+ self.search(cr, uid, [('${1:state}', '${2:=}', '${3:done}')], context=context)${4}
153 snippet create
154- id = self.create(cr, uid, ${1:vals}, context=context)
155+ id = self.create(cr, uid, ${1:vals}, context=context)${2}
156 snippet write
157- self.write(cr, uid, ${1:ids}, ${2:vals}, context=context)
158+ self.write(cr, uid, ${1:ids}, ${2:vals}, context=context)${3}
159 snippet unlink
160- self.unlink(cr, uid, ${1:ids}, context=context)
161+ self.unlink(cr, uid, ${1:ids}, context=context)${2}
162 snippet perm_read
163- self.perm_read(cr, uid, [${1:id}], context=context)
164+ self.perm_read(cr, uid, [${1:id}], context=context)${2}
165 #
166 # Define all variables in osv.osv begin by _
167 #
168@@ -459,9 +460,9 @@
169 # Usefull Snippet
170 #
171 snippet active
172- 'active': fields.boolean('${1:Active}', help='if check, ${2:this object is always available}'),
173+ 'active': fields.boolean('${1:Active}', help='if check, ${2:this object is always available}'),${3}
174 snippet sequence
175- 'sequence': fields.integer('${1:Sequence}'),
176+ 'sequence': fields.integer('${1:Sequence}'),${2}
177 snippet logger
178 import netsvc
179 logger = netsvc.Logger()
180@@ -469,7 +470,15 @@
181 import logging
182 logger = logging.getLogger('${1:module}')
183 snippet notify
184- logger.notifyChannel('${1:module}', netsvc.${2:LOG_DEBUG}, '${3:Message}') ${4}
185+ logger.notifyChannel('${1:module}', netsvc.${2:LOG_DEBUG}, '${3:Message}')${4}
186+snippet log Debug
187+ logger.debug('${1}')
188+snippet log Info
189+ logger.info('${1}')
190+snippet log Warning
191+ logger.warning('${1}')
192+snippet log Error
193+ logger.error('${1}')
194 #
195 # Other python declaration
196 #
197
198=== modified file 'vim/snippets/xml.snippets'
199--- vim/snippets/xml.snippets 2011-12-15 15:07:28 +0000
200+++ vim/snippets/xml.snippets 2011-12-22 15:30:41 +0000
201@@ -73,13 +73,13 @@
202 snippet nol
203 nolabel="1" ${1}
204 snippet nolabel
205- nolabel="1" ${0}
206+ nolabel="1" ${1}
207 snippet readonly
208 readonly="1" ${1}
209 snippet required
210- required="1"
211+ required="1" ${1}
212 snippet invisible
213- invisible="1"
214+ invisible="1" ${1}
215 snippet pos
216 position="${1:inside}"
217 snippet position
218@@ -136,7 +136,7 @@
219 <group colspan="4" col="6">
220 <label string ="" colspan="2"/>
221 <button icon="gtk-cancel" special="cancel" string="Cancel"/>
222- <button icon="terp-gtk-go-back-rtl" string="Start" name="${5:_continue}" type="object"/>
223+ <button icon="terp-gtk-go-back-rtl" string="Start" name="${5:_continue}" type="object"/>
224 </group>
225 </form>
226 </field>
227@@ -186,8 +186,7 @@
228 <field name="object" eval="1"/>
229 <field name="key">action</field>
230 <field name="key2">client_action_multi</field>
231- <field name="model_id" ref="${5:ir_model_data}"/>
232- <field name="model">$2</field>
233+ <field name="model">${2:Model to launch wizard}</field>
234 <field name="value" eval="'ir.actions.act_window,' + str(ref('action_$1_view'))" />
235 </record>
236 snippet view form
237@@ -436,6 +435,16 @@
238 widget="selection"
239 snippet widget float_time
240 widget="float_time"
241+snippet widget url
242+ widget="url"
243+snippet widget progressbar
244+ widget="progressbar"
245+snippet widget many2many
246+ widget="many2many"
247+snippet widget one2many_list
248+ widget="one2many_list"
249+snippet widget password
250+ password="1"
251 snippet test <test expr=""/>
252 <test expr="len(${1:one2many}) == ${2:1}"/>
253 snippet test <test expr=""></test>
254@@ -460,3 +469,23 @@
255 <delete model="${1:model}" id="${2:ir_model_data}"/>
256 snippet delete search
257 <delete model="${1:model}" search="[('${2:field}', '${3:operator}', '${4:value}')]"/>
258+snippet icon gtk-apply
259+ icon="gtk-apply"
260+snippet icon gtk-cancel
261+ icon="gtk-cancel"
262+snippet icon gtk-close
263+ icon="gtk-close"
264+snippet icon gtk-convert
265+ icon="gtk-convert"
266+snippet icon gtk-execute
267+ icon="gtk-execute"
268+snippet icon gtk-go-forward
269+ icon="gtk-go-forward"
270+snippet icon gtk-jump-to
271+ icon="gtk-jump-to"
272+snippet icon gtk-media-pause
273+ icon="gtk-media-pause"
274+snippet icon gtk-ok
275+ icon="gtk-ok"
276+snippet icon gtk-print
277+ icon="gtk-print"