-
Notifications
You must be signed in to change notification settings - Fork 4
/
odoo-xml-snippets.cson
executable file
·287 lines (256 loc) · 7.18 KB
/
odoo-xml-snippets.cson
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
'.text.xml':
'Create the main tags':
'prefix': 'oo_data'
'body': """
<?xml version="1.0" encoding="utf-8"?>
<odoo>
$1
</odoo>
"""
# Form, tree and search view creation
'Create form view':
'prefix': 'oo_form'
'body': """
<record id="$1_view_form" model="ir.ui.view">
<field name="name">$2.form</field>
<field name="model">$2</field>
<field name="arch" type="xml">
<form string="$3">
<sheet>
<group>
<field name="$4"/>
</group>
</sheet>
</form>
</field>
</record>
"""
'Create tree view':
'prefix': 'oo_tree'
'body': """
<record id="$1_view_tree" model="ir.ui.view">
<field name="name">$2.tree</field>
<field name="model">$2</field>
<field name="arch" type="xml">
<tree string="$3">
<field name="$4"/>
</tree>
</field>
</record>
"""
'Create search view':
'prefix': 'oo_search'
'body': """
<record id="$1_view_search" model="ir.ui.view">
<field name="name">$2.search</field>
<field name="model">$2</field>
<field name="arch" type="xml">
<tree string="$3">
<field name="$4"/>
<filter name="$5" string="$6" domain="[(\'$7\', \'=\', $8), ]"/>
</tree>
</field>
</record>
"""
'Inherit existing form view':
'prefix': 'oo_form_inherit'
'body': """
<!-- Inherit Form view -->
<record id="$1" model="ir.ui.view">
<field name="name">$2.form</field>
<field name="model">$2</field>
<field name="inherit_id" ref="$3"/>
<field name="arch" type="xml">
<field name="$4" position="$5">
<!-- Add your fields or attributes here -->
</field>
</field>
</record>
"""
'Inherit existing tree view':
'prefix': 'oo_tree_inherit'
'body': """
<record id="$1" model="ir.ui.view">
<field name="name">$2.tree</field>
<field name="model">$2</field>
<field name="inherit_id" ref="$3"/>
<field name="arch" type="xml">
<field name="$4" position="$5">
<!-- Add new fields here -->
</field>
</field>
</record>
"""
'Inherit existing search view':
'prefix': 'oo_search_inherit'
'body': """
<record id="$1" model="ir.ui.view">
<field name="name">$2.search</field>
<field name="model">$2</field>
<field name="inherit_id" ref="$3"/>
<field name="arch" type="xml">
<field name="$4" position="$5">
<!-- Add new fields or filters here -->
</field>
</field>
</record>
"""
'Add Form\'s header with \'state\' and buttons':
'prefix': 'oo_form_header'
'body': """
<header>
<button name="$1" string="$2" class="oe_highlight" states="$3" type="$4"/>
<field name="state" widget="statusbar" statusbar_visible="$5" statusbar_colors="{'KEY_IS_STATE':'VALUE_IS_COLOR'}"/>
</header>
"""
# Action
'Create new action':
'prefix': 'oo_action'
'body': """
<record id="$1_action_form" model="ir.actions.act_window">
<field name="name">$2</field>
<field name="res_model">$3</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
<!-- Add Text Here -->
</p>
<p>
<!-- More details about what a user can do -->
</p>
</field>
</record>
"""
# Menuitem
'Create menu item in the upper bar':
'prefix': 'oo_menuitem_root'
'body': '<menuitem id="menu_$1" name="$2" sequence="$3"/>'
'Create menu item for category':
'prefix': 'oo_menuitem_category'
'body': '<menuitem id="menu_$1" name="$2" parent="$3" sequence="$4"/>'
'Create menu item for actions':
'prefix': 'oo_menuitem_action'
'body': '<menuitem id="menu_$1" name="$2" parent="$3" action="$4" sequence="$5"/>'
# Common structures
'Add nested groups':
'prefix': 'oo_nested_group'
'body': """
<group string="$1">
<group>
<field name="$2"/>
</group>
<group>
<field name="$3"/>
</group>
</group>
"""
'Add notebook and a page':
'prefix': 'oo_notebook'
'body': """
<notebook>
<page string="$1">
<group>
<field name="$2"/>
</group>
</page>
</notebook>
"""
'Add page':
'prefix': 'oo_page'
'body': """
<page string="$1">
<group>
<field name="$2"/>
</group>
</page>
"""
'Add domain to a field':
'prefix': 'oo_domain'
'body': 'domain="[(\'$1\', \'=\', $2), ]"'
# Security
'Create security category':
'prefix': 'oo_security_category'
'body': """
<record id="module_category_$1" model="ir.module.category">
<field name="name">$2</field>
<field name="sequence">$3</field>
</record>
"""
'Create group, then assign new permissions':
'prefix': 'oo_security_group'
'body': """
<record id="group_$1" model="res.groups">
<field name="name">$2</field>
<field name="category_id" ref="$3"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
"""
'Create security rules':
'prefix': 'oo_security_rule'
'body': """
<record id="rule_$1" model="ir.rule">
<field name="name">$2</field>
<field name="model_id" ref="model_$3"/>
<field name="domain_force">[(\'$4\', \'=\', $5), ]</field>
<field name="perm_write" eval="1"/>
<field name="perm_create" eval="1"/>
<field name="perm_read" eval="1"/>
<field name="perm_unlink" eval="1"/>
<!-- You can attach this rule to a specific group, or make it global -->
<field name="groups" eval="[(4, ref('group_id'))]"/>
<!--<field name="global" eval="1"/> -->
</record>
"""
# Workflow
'Create workflow':
'prefix': 'oo_wkf'
'body': """
<record id="wkf_$1" model="workflow">
<field name="name">$2</field>
<field name="osv">$3</field>
<field name="on_create">True</field>
</record>
"""
'Add transition to workflow':
'prefix': 'oo_wkf_transition'
'body': """
<record id="trans_$1" model="workflow.transition">
<field name="act_from" ref="$2"/>
<field name="act_to" ref="$3"/>
<field name="signal">$4</field>
</record>
"""
'Add activity to workflow':
'prefix': 'oo_wkf_activity'
'body': """
<record id="act_$1" model="workflow.activity">
<field name="wkf_id" ref="$2"/>
<field name="name">$3</field>
<!--<field name="flow_start">True</field>-->
<!--<field name="flow_stop">True</field>-->
<field name="kind">function</field>
<field name="action">$4</field>
</record>
"""
# Misc
'Add Social Messaging and followers':
'prefix': 'oo_form_social'
'body': """
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
"""
# Smart Buttons
'Add Smart Button Type=Action':
'prefix': 'oo_smart_button_action'
'body': """
<xpath expr="//div[@name='button_box']" position="inside">
<!-->O posicionamento é na div sheet<-->
<button type="action" class="oe_stat_button" icon="fa-money"
name="%(external name da action a ser chamada)d"
context="{'search_default_partner_id': active_id, 'default_partner_id': active_id}">
<field string="Bank account(s)" name="bank_account_count" widget="statinfo"/>
</button>
</xpath>
"""