Skip to content

Commit eb24e0d

Browse files
author
Cristian Sebastian Rocha
committed
[FIX] Dont get inhereted workflow. [ADD] Generate Search view.
1 parent c52137c commit eb24e0d

File tree

11 files changed

+249
-43
lines changed

11 files changed

+249
-43
lines changed

TODO

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
! Test files: XMI files with one class
22

3-
TODO: Agregar tag action: que hace el menu.
4-
TODO: Agregar tag view: dice que tipo de accion hace (form, tree, search, etc.)
5-
TODO: Agregar tag category: indica a que categoria de aplicación pertenece el modulo.
6-
TODO: Agregar tag trigger_model: Para transiciones ver: http://forum.openerp.com/forum/topic23980.html
7-
TODO: Agregar tag trigger_expre_id: Para transiciones ver: http://forum.openerp.com/forum/topic23980.html
3+
-TODO: Agregar tag action: que hace el menu.
4+
-TODO: Agregar tag view: dice que tipo de accion hace (form, tree, search, etc.)
5+
-TODO: Agregar tag category: indica a que categoria de aplicación pertenece el modulo.
6+
-TODO: Agregar tag trigger_model: Para transiciones ver: http://forum.openerp.com/forum/topic23980.html
7+
-TODO: Agregar tag trigger_expre_id: Para transiciones ver: http://forum.openerp.com/forum/topic23980.html
8+
-TODO: Agregar tag module_groups: Para indicar que grupos tienen acceso a un campo.
9+
-TODO: Agregar tag view_groups: Para indicar que el campo es visible para esos grupos.
810

911
---
1012
TODO: Implementar sub-flujos.

xmi2oerp/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
import uml
2424
import model
2525
import builder
26+
import validation
2627

2728
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

xmi2oerp/builder.py

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,26 @@
2727
from datetime import date
2828
from pprint import PrettyPrinter
2929
import logging
30-
import cgi
30+
from xml.sax.saxutils import quoteattr, escape
3131
import itertools
3232

33+
def names(items):
34+
return [ i.name.encode('ascii', 'ignore') for i in items ]
35+
36+
def stereotype_dict(items, attribute, dictmap, default=None, prefix=None, suffix=None):
37+
prefix = prefix or ''
38+
suffix = suffix or ''
39+
stereotypes = set(dictmap.keys())
40+
r = {}
41+
for i in items:
42+
k = '%s%s%s' % (prefix, getattr(i, attribute).encode('ascii', 'ignore'), suffix)
43+
active_stereotypes = stereotypes & set(names(i.stereotypes))
44+
if len(active_stereotypes) > 0:
45+
r[k] = dictmap[active_stereotypes.pop()]
46+
elif default is not None:
47+
r[k] = default
48+
return r
49+
3350
class Builder:
3451
"""Builder engine for addons.
3552
@@ -141,18 +158,24 @@ def build(self, logfile=sys.stderr):
141158
root_classes = [ (c.xmi_id, c.name) for c in package.get_entities(uml.CClass) ]
142159
wizard_classes = [] # [ (c.xmi_id, c.name) for c in package.classes ]
143160
report_classes = [] # [ (c.xmi_id, c.name) for c in package.classes ]
144-
view_files = [ '%s_view.xml' % name for xml_id, name in root_classes ]
145-
menu_files = [ '%s_menuitem.xml' % package.name ]
146-
group_files = [ '%s_group.xml' % package.name ]
147-
workflow_files = [ '%s_workflow.xml' % name for xml_id, name in root_classes if len(self.model[xml_id].statemachines)>0 ]
161+
view_files = [ 'view/%s_view.xml' % name for xml_id, name in root_classes ]
162+
menu_files = [ 'view/%s_menuitem.xml' % package.name ]
163+
group_files = [ 'security/%s_group.xml' % package.name ]
164+
workflow_files = [ 'workflow/%s_workflow.xml' % name for xml_id, name in root_classes if len(self.model[xml_id].statemachines)>0 ]
148165
app_files = [ '%s_app.xml' % package.name ]
166+
security_files = [ 'security/ir.model.access.csv' ]
149167
# Calcula dependencias
150168
dependencies = set([ self.model[ass].name for ass in self.model.iterclass(uml.CPackage) ]) \
151169
- set(['res', 'ir', package.name])
152170
# Construyo los tags
153171
tags = {
154-
'escape': cgi.escape,
172+
'stereotype_dict': stereotype_dict,
173+
'names': names,
174+
'escape': escape,
175+
'quote': lambda s: escape(s, {'"':'"', "'":'"'}),
176+
'doublequote': lambda s: escape(s, {"'":'"'}),
155177
'uml': uml,
178+
'PACKAGE': package,
156179
'YEAR': str(date.today().year),
157180
'MODULE_NAME': package.name,
158181
'MODULE_LABEL': ptag.get('label', package.name),
@@ -189,7 +212,7 @@ def build(self, logfile=sys.stderr):
189212
'depends': list(dependencies),
190213
'init_xml': [],
191214
'demo_xml': [],
192-
'update_xml': group_files + view_files + menu_files + workflow_files,
215+
'update_xml': group_files + view_files + menu_files + workflow_files + security_files,
193216
'test': [],
194217
'active': False,
195218
'installable': True,
@@ -204,17 +227,23 @@ def build(self, logfile=sys.stderr):
204227
'*PACKAGE_*'))
205228

206229
# Generate menu file
207-
source_code = os.path.join(source, 'PACKAGE_menuitem.xml')
208-
target_code = os.path.join(target, '%s_menuitem.xml' % package.name)
230+
source_code = os.path.join(source, 'view/PACKAGE_menuitem.xml')
231+
target_code = os.path.join(target, 'view/%s_menuitem.xml' % package.name)
209232
shutil.copy(source_code, target_code)
210233
self.update(tags, target_code)
211234

212235
# Generate groups file
213-
source_code = os.path.join(source, 'PACKAGE_group.xml')
214-
target_code = os.path.join(target, '%s_group.xml' % package.name)
236+
source_code = os.path.join(source, 'security/PACKAGE_group.xml')
237+
target_code = os.path.join(target, 'security/%s_group.xml' % package.name)
215238
shutil.copy(source_code, target_code)
216239
self.update(tags, target_code)
217240

241+
# Security file
242+
#source_code = os.path.join(source, 'security/ir.model.access.csv')
243+
#target_code = os.path.join(target, 'security/ir.model.access.csv')
244+
#shutil.copy(source_code, target_code)
245+
#self.update(tags, target_code)
246+
218247
# Proceso el template basico sobre los archivos copiados.
219248
for root, dirs, files in os.walk(target):
220249
for f in files:
@@ -261,18 +290,17 @@ def build(self, logfile=sys.stderr):
261290
self.update(tags, target_code)
262291

263292
# Generate view file
264-
source_code = os.path.join(source, 'CLASS_view.xml')
265-
target_code = os.path.join(target, '%s_view.xml' % name)
293+
source_code = os.path.join(source, 'view/CLASS_view.xml')
294+
target_code = os.path.join(target, 'view/%s_view.xml' % name)
266295
shutil.copy(source_code, target_code)
267296
self.update(tags, target_code)
297+
268298
# Generate workflow file
269-
if len(cclass.statemachines) > 0:
270-
source_code = os.path.join(source, 'CLASS_workflow.xml')
271-
target_code = os.path.join(target, '%s_workflow.xml' % name)
299+
if len(list(cclass.iter_over_inhereted_attrs('statemachines'))) > 0:
300+
source_code = os.path.join(source, 'workflow/CLASS_workflow.xml')
301+
target_code = os.path.join(target, 'workflow/%s_workflow.xml' % name)
272302
shutil.copy(source_code, target_code)
273303
self.update(tags, target_code)
274-
# TODO: Generate access rules.
275-
# TODO: Creaate groups.
276304

277305
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
278306

xmi2oerp/data/OpenObjectStadardElements.xmi

Lines changed: 89 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version = '1.0' encoding = 'UTF-8' ?>
2-
<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Sat Dec 22 08:55:51 ART 2012'>
2+
<XMI xmi.version = '1.2' xmlns:UML = 'org.omg.xmi.namespace.UML' timestamp = 'Wed Jan 16 21:14:28 ART 2013'>
33
<XMI.header> <XMI.documentation>
44
<XMI.exporter>ArgoUML (using Netbeans XMI Writer version 1.0)</XMI.exporter>
55
<XMI.exporterVersion>0.34(6) revised on $Date: 2010-01-11 22:20:14 +0100 (Mon, 11 Jan 2010) $ </XMI.exporterVersion>
@@ -68,8 +68,8 @@
6868
<UML:Stereotype xmi.id = '127-0-1-1--66344949:13b09938a14:-8000:0000000000000BA1'
6969
name = 'readonly' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
7070
isAbstract = 'false'>
71-
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
7271
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
72+
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
7373
<UML:ModelElement.taggedValue>
7474
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D1C'
7575
isSpecification = 'false'>
@@ -83,8 +83,8 @@
8383
<UML:Stereotype xmi.id = '127-0-1-1--66344949:13b09938a14:-8000:0000000000000BA2'
8484
name = 'required' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
8585
isAbstract = 'false'>
86-
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
8786
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
87+
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
8888
<UML:ModelElement.taggedValue>
8989
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D1D'
9090
isSpecification = 'false'>
@@ -98,8 +98,8 @@
9898
<UML:Stereotype xmi.id = '127-0-1-1--66344949:13b09938a14:-8000:0000000000000BA3'
9999
name = 'select' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
100100
isAbstract = 'false'>
101-
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
102101
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
102+
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
103103
<UML:ModelElement.taggedValue>
104104
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D1F'
105105
isSpecification = 'false'>
@@ -113,8 +113,8 @@
113113
<UML:Stereotype xmi.id = '127-0-1-1--66344949:13b09938a14:-8000:00000000000011E5'
114114
name = 'form' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
115115
isAbstract = 'false'>
116-
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
117116
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
117+
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
118118
<UML:ModelElement.taggedValue>
119119
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D19'
120120
isSpecification = 'false'>
@@ -128,8 +128,8 @@
128128
<UML:Stereotype xmi.id = '127-0-1-1--66344949:13b09938a14:-8000:00000000000011E6'
129129
name = 'tree' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
130130
isAbstract = 'false'>
131-
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
132131
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
132+
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
133133
<UML:ModelElement.taggedValue>
134134
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D23'
135135
isSpecification = 'false'>
@@ -143,8 +143,8 @@
143143
<UML:Stereotype xmi.id = '127-0-1-1--66344949:13b09938a14:-8000:00000000000011E8'
144144
name = 'store' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
145145
isAbstract = 'false'>
146-
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
147146
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
147+
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
148148
<UML:ModelElement.taggedValue>
149149
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D21'
150150
isSpecification = 'false'>
@@ -191,8 +191,8 @@
191191
<UML:Stereotype xmi.id = '127-0-1-1--66344949:13b09938a14:-8000:00000000000011F5'
192192
name = 'method' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
193193
isAbstract = 'false'>
194-
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
195194
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
195+
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
196196
<UML:ModelElement.taggedValue>
197197
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D1B'
198198
isSpecification = 'false'>
@@ -374,8 +374,8 @@
374374
<UML:Stereotype xmi.id = '127-0-1-1-7b01ca01:13b51db18aa:-8000:0000000000000D12'
375375
name = 'hidden' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
376376
isAbstract = 'false'>
377-
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
378377
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
378+
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
379379
<UML:ModelElement.taggedValue>
380380
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D1A'
381381
isSpecification = 'false'>
@@ -389,8 +389,8 @@
389389
<UML:Stereotype xmi.id = '127-0-1-1--7f493fcf:13b6d9e307b:-8000:0000000000000F56'
390390
name = 'search' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
391391
isAbstract = 'false'>
392-
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
393392
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
393+
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
394394
<UML:ModelElement.taggedValue>
395395
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D1E'
396396
isSpecification = 'false'>
@@ -407,8 +407,8 @@
407407
<UML:Stereotype xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D17'
408408
name = 'state' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
409409
isAbstract = 'false'>
410-
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
411410
<UML:Stereotype.baseClass>Attribute</UML:Stereotype.baseClass>
411+
<UML:Stereotype.baseClass>AssociationEnd</UML:Stereotype.baseClass>
412412
<UML:ModelElement.taggedValue>
413413
<UML:TaggedValue xmi.id = '127-0-1-1-608aa393:13b6da4b8d4:-8000:0000000000000D20'
414414
isSpecification = 'false'>
@@ -434,7 +434,7 @@
434434
</UML:ModelElement.taggedValue>
435435
</UML:Stereotype>
436436
<UML:TagDefinition xmi.id = '127-0-1-1-19e0703c:13b6dbe7adf:-8000:00000000000011CA'
437-
name = 'view_group' isSpecification = 'false'>
437+
name = 'view_groups' isSpecification = 'false'>
438438
<UML:TagDefinition.multiplicity>
439439
<UML:Multiplicity xmi.id = '127-0-1-1-19e0703c:13b6dbe7adf:-8000:00000000000011CC'>
440440
<UML:Multiplicity.range>
@@ -476,6 +476,83 @@
476476
</UML:Multiplicity>
477477
</UML:TagDefinition.multiplicity>
478478
</UML:TagDefinition>
479+
<UML:TagDefinition xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E93'
480+
name = 'action' isSpecification = 'false'>
481+
<UML:TagDefinition.multiplicity>
482+
<UML:Multiplicity xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E95'>
483+
<UML:Multiplicity.range>
484+
<UML:MultiplicityRange xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E94'
485+
lower = '0' upper = '0'/>
486+
</UML:Multiplicity.range>
487+
</UML:Multiplicity>
488+
</UML:TagDefinition.multiplicity>
489+
</UML:TagDefinition>
490+
<UML:TagDefinition xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E96'
491+
name = 'trigger_expre_id' isSpecification = 'false'>
492+
<UML:TagDefinition.multiplicity>
493+
<UML:Multiplicity xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E98'>
494+
<UML:Multiplicity.range>
495+
<UML:MultiplicityRange xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E97'
496+
lower = '0' upper = '0'/>
497+
</UML:Multiplicity.range>
498+
</UML:Multiplicity>
499+
</UML:TagDefinition.multiplicity>
500+
</UML:TagDefinition>
501+
<UML:TagDefinition xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E99'
502+
name = 'view' isSpecification = 'false'>
503+
<UML:TagDefinition.multiplicity>
504+
<UML:Multiplicity xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E9B'>
505+
<UML:Multiplicity.range>
506+
<UML:MultiplicityRange xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E9A'
507+
lower = '0' upper = '0'/>
508+
</UML:Multiplicity.range>
509+
</UML:Multiplicity>
510+
</UML:TagDefinition.multiplicity>
511+
</UML:TagDefinition>
512+
<UML:TagDefinition xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E9C'
513+
name = 'category' isSpecification = 'false'>
514+
<UML:TagDefinition.multiplicity>
515+
<UML:Multiplicity xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E9E'>
516+
<UML:Multiplicity.range>
517+
<UML:MultiplicityRange xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E9D'
518+
lower = '0' upper = '0'/>
519+
</UML:Multiplicity.range>
520+
</UML:Multiplicity>
521+
</UML:TagDefinition.multiplicity>
522+
</UML:TagDefinition>
523+
<UML:TagDefinition xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000E9F'
524+
name = 'trigger_model' isSpecification = 'false'>
525+
<UML:TagDefinition.multiplicity>
526+
<UML:Multiplicity xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000EA1'>
527+
<UML:Multiplicity.range>
528+
<UML:MultiplicityRange xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000EA0'
529+
lower = '0' upper = '0'/>
530+
</UML:Multiplicity.range>
531+
</UML:Multiplicity>
532+
</UML:TagDefinition.multiplicity>
533+
</UML:TagDefinition>
534+
<UML:TagDefinition xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000EA2'
535+
name = 'module_groups' isSpecification = 'false'>
536+
<UML:TagDefinition.multiplicity>
537+
<UML:Multiplicity xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000EA4'>
538+
<UML:Multiplicity.range>
539+
<UML:MultiplicityRange xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000EA3'
540+
lower = '0' upper = '0'/>
541+
</UML:Multiplicity.range>
542+
</UML:Multiplicity>
543+
</UML:TagDefinition.multiplicity>
544+
</UML:TagDefinition>
545+
<UML:Stereotype xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000EAE'
546+
name = 'button' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
547+
isAbstract = 'false'>
548+
<UML:Stereotype.baseClass>Operation</UML:Stereotype.baseClass>
549+
<UML:Stereotype.baseClass>SignalEvent</UML:Stereotype.baseClass>
550+
</UML:Stereotype>
551+
<UML:Stereotype xmi.id = '127-0-1-1-f7a661d:13c45d154b1:-8000:0000000000000EAF'
552+
name = 'default' isSpecification = 'false' isRoot = 'false' isLeaf = 'false'
553+
isAbstract = 'false'>
554+
<UML:Stereotype.baseClass>Transition</UML:Stereotype.baseClass>
555+
</UML:Stereotype>
479556
</UML:Namespace.ownedElement>
480557
</UML:Model>
481558
</XMI.content>
223 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)