├── lib
└── main.coffee
├── CHANGELOG.md
├── package.json
├── LICENSE.md
├── README.md
└── snippets
├── odoo-python-snippets.cson
└── odoo-xml-snippets.cson
/lib/main.coffee:
--------------------------------------------------------------------------------
1 | module.exports =
2 | activate: (state) ->
3 |
4 | deactivate: ->
5 |
6 | serialize: ->
7 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.4.0
2 |
3 | * Change prefix to `odoo_`
4 |
5 | ## 0.3.2
6 |
7 | * Fix HTML field (issue #6)
8 |
9 | ## 0.3.1
10 |
11 | * Minor fix
12 |
13 | ## 0.3.0
14 |
15 | * Global improvements for Python snippets (placeholders, better relational fields...)
16 |
17 | ## 0.2.0
18 |
19 | * Remove useless xpath
20 |
21 | ## 0.1.0
22 |
23 | * Initial release
24 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "odoo-snippets",
3 | "main": "./lib/main",
4 | "version": "0.5.0",
5 | "description": "Snippets for the Odoo software development",
6 | "keywords": [
7 | "snippets",
8 | "odoo",
9 | "python",
10 | "xml"
11 | ],
12 | "activationCommands": {},
13 | "repository": "https://github.com/DocMarty84/atom-odoo-snippets",
14 | "license": "MIT",
15 | "engines": {
16 | "atom": ">0.50.0"
17 | },
18 | "dependencies": {}
19 | }
20 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Nicolas Martinelli
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # atom-odoo-snippets
2 |
3 | Add snippets for the Odoo software development to the Atom editor. Snippets are
4 | provided for Python and XML sources. All snippets start with prefix 'odoo_'.
5 |
6 | Python snippets:
7 | - Create new Odoo object
8 | - Inherit/Extend existing Odoo object
9 | - Add new field of type Integer, Char, Text, Many2one, One2many, Many2many,
10 | Boolean, HTML, Float, Date, DateTime, Selection, Binary
11 | - Call to search and name_search
12 | - Create method for compute, onchange, constrains
13 | - Add a computed field with appropriate methods
14 |
15 | XML snippets:
16 | - Create the main tags
17 | - Create Form/Tree/Search view
18 | - Inherit existing Form/Tree/Search view
19 | - Add Form's header with 'state' and buttons
20 | - Create action
21 | - Create menu item for any of the 3 levels (upper bar, category, action)
22 | - Add nested groups, notebook and page, page
23 | - Add domain to a field
24 | - Create security category
25 | - Create group, then assign new permissions
26 | - Create security rules
27 | - Create workflow
28 | - Add transition or activity to an existing workflow
29 | - Add social messaging and followers
30 |
31 | Inspired by the project odoo-pycharm-templates:
32 | https://github.com/mohamedmagdy/odoo-pycharm-templates
33 |
--------------------------------------------------------------------------------
/snippets/odoo-python-snippets.cson:
--------------------------------------------------------------------------------
1 | '.source.python':
2 |
3 | # Odoo objects
4 |
5 | 'Create New Odoo Object':
6 | 'prefix': 'odoo_object'
7 | 'body': """
8 | class ${10:NewModule}(models.Model):
9 | _name = "${20:module.name}"
10 | _rec_name = "${30:module.rec_name}" # optional
11 | _description = "${40:Module description}"
12 | _order = "${50:field1}, ${60:field2}, " # optional
13 |
14 | name = fields.Char()$70
15 | """
16 |
17 | 'Inherit/Extend Existing Odoo Object':
18 | 'prefix': 'odoo_object_inherit'
19 | 'body': """
20 | class ${10:NewModule}(models.Model):
21 | _name = "${20:module.name}" # optional
22 | _inherit = "${30:module.name}"
23 |
24 | name = fields.Char()$40
25 | """
26 |
27 | # Odoo fields
28 |
29 | 'Integer Field':
30 | 'prefix': 'odoo_field_integer'
31 | 'body': '${5:new_field} = fields.Integer(string="${10:Field name}", )'
32 |
33 | 'Float Field':
34 | 'prefix': 'odoo_field_float'
35 | 'body': '${5:new_field} = fields.Float(string="${10:Field name}", )'
36 |
37 | 'Char Field':
38 | 'prefix': 'odoo_field_char'
39 | 'body': '${5:new_field} = fields.Char(string="${10:Field name}", )'
40 |
41 | 'Text Field':
42 | 'prefix': 'odoo_field_text'
43 | 'body': '${5:new_field} = fields.Text(string="${10:Field name}", )'
44 |
45 | 'Many2one Field':
46 | 'prefix': 'odoo_field_many2one'
47 | 'body': '''
48 | ${10:new_field_id} = fields.Many2one(
49 | string="${20:Field name}",
50 | comodel_name="${30:res.partner}",
51 | domain="[('${40:field}', '${41:=}', ${42:other})]",
52 | context={"${50:key}": ${51:"value"}\\},
53 | ondelete="${60:set null}",
54 | help="${70:Explain your field}.",
55 | )$80
56 | '''
57 |
58 | 'One2many Field':
59 | 'prefix': 'odoo_field_one2many'
60 | 'body': '''
61 | ${10:new_field_ids} = fields.One2many(
62 | string="${20:Field name}",
63 | comodel_name="${30:res.partner}",
64 | inverse_name="${40:inverse_name_id}",
65 | domain="[('${50:field}', '${51:=}', ${52:other})]",
66 | context={"${60:key}": ${61:"value"}\\},
67 | help="${70:Explain your field}.",
68 | )$80
69 | '''
70 |
71 | 'Many2many Field':
72 | 'prefix': 'odoo_field_many2many'
73 | 'body': '''
74 | ${10:new_field_ids} = fields.Many2many(
75 | string="${20:Field name}",
76 | comodel_name="${30:res.partner}",
77 | relation="${40:relation_table_name}",
78 | column1="${50:column_this}",
79 | column2="${60:column_other}",
80 | domain="[('${70:field}', '${71:=}', ${72:other})]",
81 | context={"${80:key}": ${81:"value"}\\},
82 | help="${90:Explain your field}.",
83 | )$100
84 | '''
85 |
86 | 'Boolean Field':
87 | 'prefix': 'odoo_field_boolean'
88 | 'body': '${5:is_new_field} = fields.Boolean(string="${10:Field name}", )'
89 |
90 | 'HTML Field':
91 | 'prefix': 'odoo_field_html'
92 | 'body': '${5:new_field} = fields.Html(string="${10:Field name}", )'
93 |
94 | 'Date Field':
95 | 'prefix': 'odoo_field_date'
96 | 'body': '${5:new_field} = fields.Date(string="${10:Field name}", )'
97 |
98 | 'DateTime Field':
99 | 'prefix': 'odoo_field_datetime'
100 | 'body': '${5:new_field} = fields.Datetime(string="${10:Field name}", )'
101 |
102 | 'Selection Field':
103 | 'prefix': 'odoo_field_selection'
104 | 'body': '''
105 | ${5:new_field} = fields.Selection(
106 | string="${10:Field name}",
107 | selection=[
108 | (\'${20:value1}\', \'${21:description1}\'),
109 | (\'${30:value2}\', \'${31:description2}\'),
110 | ],$40
111 | )$50
112 | '''
113 |
114 | 'Binary Field':
115 | 'prefix': 'odoo_field_binary'
116 | 'body': '${5:new_field} = fields.Binary(string="${10:Field name}", )'
117 |
118 | # Call to common Odoo methods
119 |
120 | 'Search':
121 | 'prefix': 'odoo_search'
122 | 'body': 'self.search([(\'$1\', \'=\', $2), ...], offset=0, limit=None, order=None, count=False)'
123 |
124 | 'Name search':
125 | 'prefix': 'odoo_search_name'
126 | 'body': 'self.name_search(name=\'$1\', args=None, operator=\'ilike\', limit=100)'
127 |
128 | # Creation of common Odoo methods
129 |
130 | 'Compute method':
131 | 'prefix': 'odoo_method_compute'
132 | 'body': """
133 | @api.multi
134 | @api.depends("${10:field1}", "${20:field2}", )
135 | def _compute_${30:field}(self):
136 | for s in self:
137 | ${40:pass}
138 | """
139 |
140 | 'Onchange method':
141 | 'prefix': 'odoo_onchange_method'
142 | 'body': """
143 | @api.onchange("${10:field1}", "${20:field2}", )
144 | def _onchange_${30:field}(self):
145 | vals = {}
146 |
147 | # Remove warning if necessary
148 | vals['warning'] = {
149 | 'title': _('$40')
150 | 'message': _('$50')
151 | }
152 |
153 | # Remove domain if necessary
154 | vals['domain'] = {
155 | "${60:field}": [("$61", "${62:=}", ${63:value})],
156 | }
157 |
158 | return vals$70
159 | """
160 |
161 | 'Constrains method':
162 | 'prefix': 'odoo_constrains_method'
163 | 'body': """
164 | @api.multi
165 | @api.constrains("${10:field1}", "${20:field2}", )
166 | def _check_${30:field}(self):
167 | for s in self:
168 | if s.${40:field} == ${50:value}:
169 | raise ValidationError(_("$60"))$70
170 | """
171 |
172 | # Complex Odoo fields
173 |
174 | 'Compute field':
175 | 'prefix': 'ododoo_field_compute'
176 | 'body': """
177 | ${10:new_field} = fields.${20:Float}(
178 | string="${30:Field string}",
179 | compute='_compute_${10:new_field}',
180 | inverse='_inverse_${10:new_field}',
181 | search='_search_${10:new_field}',
182 | help="$50",
183 | )
184 |
185 | @api.multi
186 | @api.depends("${60:field1}", "${70:field2}", )
187 | def _compute_${10:new_field}(self):
188 | for s in self:
189 | ${80:pass}
190 |
191 | @api.multi
192 | def _inverse_${10:new_field}(self):
193 | for s in self:
194 | ${90:pass}
195 |
196 | @api.multi
197 | def _search_${10:new_field}(self, operator, value):
198 | if operator == 'like':
199 | operator = 'ilike'
200 | return [('${100:new_field}', operator, value)]}
201 | """
202 |
--------------------------------------------------------------------------------
/snippets/odoo-xml-snippets.cson:
--------------------------------------------------------------------------------
1 | '.text.xml':
2 | 'Create the main tags':
3 | 'prefix': 'odoo_data'
4 | 'body': """
5 |
6 |
129 |
130 |
132 |
133 |