Skip to content

Commit 7dc2b1d

Browse files
committed
[REF] start refactor for 7 version. In order to have something simple snippet should support 1 version of OpenERP. If you work with multi OpenERP version, you should active/unactive the snippet used in your vim
1 parent 62109e6 commit 7dc2b1d

File tree

2 files changed

+46
-104
lines changed

2 files changed

+46
-104
lines changed

snippets/python.snippets

Lines changed: 26 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,53 @@
1-
snippet #!
2-
#!/usr/bin/env python
3-
snippet coding
4-
# -*- coding: ${1:utf-8} -*-
5-
snippet imp
6-
import ${1:module}
7-
snippet from
8-
from ${1:module} import ${2:class}
9-
snippet osv <= 6.0
10-
from osv import osv
11-
from osv import fields
1+
snippet imodel
2+
from openerp.osv import fields, orm
123
${1}
13-
snippet osv >= 6.1
14-
from openerp.osv import osv
15-
from openerp.osv import fields
4+
snippet ifield
5+
from openerp.osv import fields, orm
166
${1}
17-
# Module Docstring
18-
snippet docs
19-
'''
20-
File: ${1:`Filename('$1.py', 'foo.py')`}
21-
Author: ${2:`g:snips_author`}
22-
Description: ${3}
23-
'''
24-
snippet wh
25-
while ${1:condition}:
26-
${2:# code...}
27-
snippet for
28-
for ${1:needle} in ${2:haystack}:
29-
${3:# code...}
30-
# New Class
31-
snippet cl
32-
class ${1:ClassName}(${2:object}):
33-
"""${3:docstring for $1}"""
34-
def __init__(self, ${4:arg}):
35-
${5:super($1, self).__init__()}
36-
self.$4 = $4
37-
${6}
38-
snippet copyright
39-
##############################################################################
7+
snippet start
8+
# -*- coding: utf-8 -*-
9+
###############################################################################
4010
#
41-
# ${1:ModuleName} module for OpenERP, ${2:Description}
42-
# Copyright (C) ${3:200X} ${4:Company} (<http://${5:website}>) ${6:author}
11+
# ${1:modulename} for OpenERP
12+
# Copyright (C) 2013 Akretion (http://www.akretion.com).
13+
# @author Sébastien BEAU <sebastien.beau@akretion.com>
4314
#
44-
# This file is a part of $1
15+
# This program is free software: you can redistribute it and/or modify
16+
# it under the terms of the GNU Affero General Public License as
17+
# published by the Free Software Foundation, either version 3 of the
18+
# License, or (at your option) any later version.
4519
#
46-
# $1 is free software: you can redistribute it and/or modify
47-
# it under the terms of the GNU General Public License as published by
48-
# the Free Software Foundation, either version 3 of the License, or
49-
# (at your option) any later version.
20+
# This program is distributed in the hope that it will be useful,
21+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
# GNU Affero General Public License for more details.
5024
#
51-
# $1 is distributed in the hope that it will be useful,
52-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
53-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54-
# GNU General Public License for more details.
25+
# You should have received a copy of the GNU Affero General Public License
26+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
5527
#
56-
# You should have received a copy of the GNU General Public License
57-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
58-
#
59-
##############################################################################
60-
${7}
61-
snippet config
62-
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
63-
# this snippet is usefull to clear the rule cache
64-
# specialy with OpenObject 5.2 and multi company
65-
snippet rule
66-
self.pool.get('ir.rule').domain_get.clear_cache(cr.dbname)
28+
###############################################################################
29+
${2}
30+
6731
#
6832
# Define class for OpenObject
6933
#
7034
snippet oo Open Object\Model
71-
class ${1:ClassName}(osv.osv):
35+
class ${1:ClassName}(orm.Model):
7236
_name = '${2:ObjectName}'
7337
_description = '${3}'
7438

7539
_columns = {
7640
${4}
7741
}
7842

79-
$1()
80-
8143
snippet ooi Open Object\Model Inherit
82-
class ${1:ClassName}(osv.osv):
44+
class ${1:ClassName}(orm.Model):
8345
_inherit = '${2:ObjectName}'
8446

8547
_columns = {
8648
${3}
8749
}
8850

89-
$1()
90-
9151
snippet oom Open Object\Wizard
9252
class ${1:ClassName}(osv.osv_memory):
9353
_name = '${2:ObjectName}'
@@ -162,9 +122,7 @@ snippet required
162122
required=True, ${1}
163123
snippet translate argument
164124
translate=True, ${1}
165-
snippet translate import OpenERP <= 6.0
166-
from tools.translate import _
167-
snippet translate import OpenERP >= 6.1
125+
snippet translate
168126
from openerp.tools.translate import _
169127
snippet dp
170128
digits_compute=dp.get_precision('${1:PrecisionName}'), ${2}
@@ -595,9 +553,6 @@ snippet ifcontext
595553
if context is None:
596554
context = {}
597555
${1}
598-
snippet pdb
599-
import pdb
600-
pdb.set_trace()
601556
# workflow
602557
snippet trg trg_write
603558
wf_service = netsvc.LocalService("workflow")

snippets/xml.snippets

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ snippet wizard <wizard/>
144144
string="${2:label}"
145145
model="${3:ir.model}"
146146
name="${4:wizard_name}"/>
147-
snippet wizard osv_memory menu
147+
snippet wizard transient menu
148148
<record id="view_${1:model}_form" model="ir.ui.view">
149149
<field name="name">$2.form</field>
150150
<field name="model">${2:Model}</field>
@@ -178,15 +178,19 @@ snippet wizard osv_memory menu
178178
parent="menu_${6:menu_parent}"
179179
sequence="${7:20}"
180180
action="action_$1_view"/>
181-
snippet wizard osv_memory toolbar
181+
snippet wizard transient toolbar
182182
<record id="view_${1:model}_form" model="ir.ui.view">
183-
<field name="name">$2.form</field>
184183
<field name="model">${2:Model}</field>
185184
<field name="type">form</field>
186-
<field name="priority" eval="8"/>
187185
<field name="arch" type="xml">
188-
<form string="${3:Label}">
189-
<field name="${4:name}" select="1"/>
186+
<form string="${3:Label}" version="7.0">
187+
<separator string="$3"/>
188+
<label string="${5:Description}"/>
189+
<footer>
190+
<button name="generate_invoice" string="Generate Invoice" type="object" class="oe_highlight"/>
191+
or
192+
<button string="Cancel" class="oe_link" special="cancel"/>
193+
</footer>
190194
</form>
191195
</field>
192196
</record>
@@ -207,15 +211,22 @@ snippet wizard osv_memory toolbar
207211
<field name="object" eval="1"/>
208212
<field name="key">action</field>
209213
<field name="key2">client_action_multi</field>
210-
<field name="model">${5:Model to launch wizard}</field>
214+
<field name="model">${4:Model to launch wizard}</field>
211215
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_$1_view'))" />
212216
</record>
217+
snippet iview
218+
<record id="view_${1:model}_$3" model="ir.ui.view">
219+
<field name="model">${2:Model}</field>
220+
<field name="type">${3:Type}</field>
221+
<field name="inherit_id" ref="${4:View to inherit}" />
222+
<field name="arch" type="xml">
223+
${5}
224+
</field>
225+
</record>
213226
snippet view form
214227
<record id="view_${1:model}_form" model="ir.ui.view">
215-
<field name="name">$2.form</field>
216228
<field name="model">${2:Model}</field>
217229
<field name="type">form</field>
218-
<field name="priority" eval="8"/>
219230
<field name="arch" type="xml">
220231
<form string="${3:Label}">
221232
<field name="${4:name}" select="1"/>
@@ -224,10 +235,8 @@ snippet view form
224235
</record>
225236
snippet view tree
226237
<record id="view_${1:model}_tree" model="ir.ui.view">
227-
<field name="name">$2.tree</field>
228238
<field name="model">${2:Model}</field>
229239
<field name="type">tree</field>
230-
<field name="priority" eval="8"/>
231240
<field name="arch" type="xml">
232241
<tree string="${3:Label}">
233242
<field name="${4:name}"/>
@@ -236,10 +245,8 @@ snippet view tree
236245
</record>
237246
snippet view search
238247
<record id="view_${1:model}_search" model="ir.ui.view">
239-
<field name="name">$2.search</field>
240248
<field name="model">${2:Model}</field>
241249
<field name="type">search</field>
242-
<field name="priority" eval="8"/>
243250
<field name="arch" type="xml">
244251
<search string="${3:Label}">
245252
<field name="${4:name}" select="True"/>
@@ -248,10 +255,8 @@ snippet view search
248255
</record>
249256
snippet view both (tree, form)
250257
<record id="view_${1:model}_tree" model="ir.ui.view">
251-
<field name="name">$2.tree</field>
252258
<field name="model">${2:Model}</field>
253259
<field name="type">tree</field>
254-
<field name="priority" eval="8"/>
255260
<field name="arch" type="xml">
256261
<tree string="${3:Label}">
257262
<field name="${4:name}"/>
@@ -260,10 +265,8 @@ snippet view both (tree, form)
260265
</record>
261266

262267
<record id="view_$1_form" model="ir.ui.view">
263-
<field name="name">$2.form</field>
264268
<field name="model">$2</field>
265269
<field name="type">form</field>
266-
<field name="priority" eval="8"/>
267270
<field name="arch" type="xml">
268271
<form string="$3">
269272
<field name="$4" select="1"/>
@@ -272,10 +275,8 @@ snippet view both (tree, form)
272275
</record>
273276
snippet view both (tree, form, search)
274277
<record id="view_${1:model}_tree" model="ir.ui.view">
275-
<field name="name">$2.tree</field>
276278
<field name="model">${2:Model}</field>
277279
<field name="type">tree</field>
278-
<field name="priority" eval="8"/>
279280
<field name="arch" type="xml">
280281
<tree string="${3:Label}">
281282
<field name="${4:name}"/>
@@ -284,21 +285,17 @@ snippet view both (tree, form, search)
284285
</record>
285286

286287
<record id="view_$1_form" model="ir.ui.view">
287-
<field name="name">$2.form</field>
288288
<field name="model">$2</field>
289289
<field name="type">form</field>
290-
<field name="priority" eval="8"/>
291290
<field name="arch" type="xml">
292291
<form string="$3">
293292
<field name="$4" select="1"/>
294293
</form>
295294
</field>
296295
</record>
297296
<record id="view_$1_search" model="ir.ui.view">
298-
<field name="name">$2.search</field>
299297
<field name="model">$2</field>
300298
<field name="type">search</field>
301-
<field name="priority" eval="8"/>
302299
<field name="arch" type="xml">
303300
<search string="$3">
304301
<field name="$4" select="True"/>
@@ -307,10 +304,8 @@ snippet view both (tree, form, search)
307304
</record>
308305
snippet view both (tree, form) + Action + Menu
309306
<record id="view_${1:model}_tree" model="ir.ui.view">
310-
<field name="name">$2.tree</field>
311307
<field name="model">${2:Model}</field>
312308
<field name="type">tree</field>
313-
<field name="priority" eval="8"/>
314309
<field name="arch" type="xml">
315310
<tree string="${3:Label}">
316311
<field name="${4:name}"/>
@@ -319,10 +314,8 @@ snippet view both (tree, form) + Action + Menu
319314
</record>
320315

321316
<record id="view_$1_form" model="ir.ui.view">
322-
<field name="name">$2.form</field>
323317
<field name="model">$2</field>
324318
<field name="type">form</field>
325-
<field name="priority" eval="8"/>
326319
<field name="arch" type="xml">
327320
<form string="$3">
328321
<field name="$4" select="1"/>
@@ -360,10 +353,8 @@ snippet view both (tree, form) + Action + Menu
360353
action="act_open_$1_view"/>
361354
snippet view both (tree, form, search) + Action + Menu
362355
<record id="view_${1:model}_tree" model="ir.ui.view">
363-
<field name="name">$2.tree</field>
364356
<field name="model">${2:Model}</field>
365357
<field name="type">tree</field>
366-
<field name="priority" eval="8"/>
367358
<field name="arch" type="xml">
368359
<tree string="${3:Label}">
369360
<field name="${4:name}"/>
@@ -372,10 +363,8 @@ snippet view both (tree, form, search) + Action + Menu
372363
</record>
373364

374365
<record id="view_$1_form" model="ir.ui.view">
375-
<field name="name">$2.form</field>
376366
<field name="model">$2</field>
377367
<field name="type">form</field>
378-
<field name="priority" eval="8"/>
379368
<field name="arch" type="xml">
380369
<form string="$3">
381370
<field name="$4" select="1"/>
@@ -384,10 +373,8 @@ snippet view both (tree, form, search) + Action + Menu
384373
</record>
385374

386375
<record id="view_$1_search" model="ir.ui.view">
387-
<field name="name">$2.search</field>
388376
<field name="model">$2</field>
389377
<field name="type">search</field>
390-
<field name="priority" eval="8"/>
391378
<field name="arch" type="xml">
392379
<search string="$3">
393380
<field name="$4" select="True"/>

0 commit comments

Comments
 (0)