Merge lp:~openerp-groupes/openobject-addons/base_module_doc_rst_improvements into lp:openobject-addons

Proposed by Julien Thewys
Status: Work in progress
Proposed branch: lp:~openerp-groupes/openobject-addons/base_module_doc_rst_improvements
Merge into: lp:openobject-addons
Diff against target: 208 lines (+88/-16) (has conflicts)
4 files modified
base_module_doc_rst/base_module_doc_rst.py (+49/-16)
base_module_doc_rst/base_module_doc_rst_view.xml (+29/-0)
base_module_doc_rst/report/report_proximity_graph.py (+4/-0)
base_module_doc_rst/wizard/generate_relation_graph.py (+6/-0)
Text conflict in base_module_doc_rst/base_module_doc_rst.py
Text conflict in base_module_doc_rst/base_module_doc_rst_view.xml
Text conflict in base_module_doc_rst/report/report_proximity_graph.py
Text conflict in base_module_doc_rst/wizard/generate_relation_graph.py
To merge this branch: bzr merge lp:~openerp-groupes/openobject-addons/base_module_doc_rst_improvements
Reviewer Review Type Date Requested Status
Raphael Collet (OpenERP) (community) Needs Fixing
Review via email: mp+78201@code.launchpad.net

This proposal supersedes a proposal from 2010-10-05.

Description of the change

This branch improves the module base_module_doc_rst by adding 3 news fields on ir.module.module:
- level: number of times a model is processed when it is in relation with another model
- filter_model_ids: filter the models taken into account to generate the relationship graph
- dot_graph: save the generated graph as a DOT file

To post a comment you must log in.
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote : Posted in a previous version of this proposal

seems good

Revision history for this message
Julien Thewys (julien-thewys) wrote : Posted in a previous version of this proposal

Looks like this has actually never been merged.
Could you make it so?

Revision history for this message
Raphael Collet (OpenERP) (rco-openerp) wrote :

There are some conflicts with the trunk. Can you please merge from trunk, resolve them, and resubmit?

Thanks,
Raphael

review: Needs Fixing
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

someone should resolve the conflicts

Unmerged revisions

4152. By Olivier Ligot

[ADD] dot_graph field on ir.module.module object

This new field allows to save the generated graph as a DOT file

4151. By Olivier Ligot

[FIX] same variable name (id)

4150. By Olivier Ligot

[ADD] filter_model_ids field on ir.module.module object

This new field allows to filter the models taken into account to generate the relationship graph

4149. By Olivier Ligot

[ADD] level field on ir.module.module object

This new field allows to specify the number of times a model is processed when it is in relation with another model.

4148. By Olivier Ligot

[REM] Useless code

4147. By Olivier Ligot

[FIX] DOT file label

4146. By Xavier (Open ERP)

[FIX] account_voucher: fix sales_reicept tests to assert on the status of 'reconciled' rather than print random stuff to stdout

4145. By Launchpad Translations on behalf of openerp

Launchpad automatic translations update.

4144. By Borja (Pexego)

[FIX] Merged Borja's branch for correction on Invoice correctd workflow action of sale order

4143. By Harry (OpenERP)

[FIX] stock_planning, hr_attendance: resolve regression after rev:4139

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'base_module_doc_rst/base_module_doc_rst.py'
2--- base_module_doc_rst/base_module_doc_rst.py 2011-01-17 09:36:23 +0000
3+++ base_module_doc_rst/base_module_doc_rst.py 2011-10-05 06:32:31 +0000
4@@ -31,21 +31,36 @@
5 _description = 'Module With Relationship Graph'
6 _columns = {
7 'file_graph': fields.binary('Relationship Graph'),
8+ 'level': fields.integer('Level', help="""Number of times a model is processed
9+when it is in relation with another model."""),
10+ 'filter_model_ids': fields.many2many('ir.model', 'module_filter_model_rel', 'module_id', 'model_id', 'Filter models'),
11+ 'dot_graph': fields.binary('Graph (DOT file)'),
12 }
13
14+<<<<<<< TREE
15 def _get_graphical_representation(self, cr, uid, model_ids, level=1, context=None):
16+=======
17+ _defaults = {
18+ 'level': 1
19+ }
20+
21+ def _get_graphical_representation(self, cr, uid, module_id, model_ids, level=1, context={}):
22+>>>>>>> MERGE-SOURCE
23 obj_model = self.pool.get('ir.model')
24 if level == 0:
25 return tuple()
26 relation = []
27+ module = self.browse(cr, uid, module_id, context=context)
28+ filter_models = [model.model for model in module.filter_model_ids]
29 for id in model_ids:
30 model_data = obj_model.browse(cr, uid, id, context=context)
31 for field in (f for f in model_data.field_id if f.ttype in ('many2many', 'many2one', 'one2many')):
32- relation.append((model_data.model, field.name, field.ttype, field.relation, field.field_description))
33- new_model_ids = obj_model.search(cr, uid, [('model', '=', field.relation)], context=context)
34- if new_model_ids:
35- model = obj_model.read(cr, uid, new_model_ids, ['id', 'name'], context=context)[0]
36- relation.extend(self._get_graphical_representation(cr, uid, model['id'], level - 1))
37+ if not filter_models or field.relation in filter_models:
38+ relation.append((model_data.model, field.name, field.ttype, field.relation, field.field_description))
39+ new_model_ids = obj_model.search(cr, uid, [('model', '=', field.relation)], context=context)
40+ if new_model_ids:
41+ model = obj_model.read(cr, uid, new_model_ids, ['id', 'name'], context=context)[0]
42+ relation.extend(self._get_graphical_representation(cr, uid, module_id, [model['id']], level - 1))
43 return tuple(relation)
44
45 def _get_structure(self, relations, main_element):
46@@ -69,7 +84,7 @@
47 'one2many': 'arrowtail="none" arrowhead="crow" color="blue" label="o2m"',
48 }[field_type]
49
50- def get_graphical_representation(self, cr, uid, model_ids, context=None):
51+ def get_graphical_representation(self, cr, uid, id, model_ids, context=None):
52 obj_model = self.pool.get('ir.model')
53 if context is None:
54 context = {}
55@@ -77,32 +92,45 @@
56 models = []
57 for obj in obj_model.browse(cr, uid, model_ids, context=context):
58 models.append(obj.model)
59- relations = set(self._get_graphical_representation(cr, uid, model_ids, context.get('level', 1)))
60+ relations = set(self._get_graphical_representation(cr, uid, id, model_ids, context.get('level', 1)))
61 res[obj.model] = "digraph G {\nnode [style=rounded, shape=record];\n%s\n%s }" % (
62 self._get_structure(relations, models),
63 ''.join('"%s":%s -> "%s":id:n [%s]; // %s\n' % (m, fn, fr, self._get_arrow(ft),ft) for m, fn, ft, fr, fl in relations),
64 )
65 return res
66
67+<<<<<<< TREE
68 def _get_module_objects(self, cr, uid, module, context=None):
69 obj_model = self.pool.get('ir.model')
70+=======
71+ def _get_module_objects(self, cr, uid, module, context={}):
72+>>>>>>> MERGE-SOURCE
73 obj_mod_data = self.pool.get('ir.model.data')
74- obj_ids = []
75 model_data_ids = obj_mod_data.search(cr, uid, [('module', '=', module), ('model', '=', 'ir.model')], context=context)
76 model_ids = []
77+ module_id = self.search(cr, uid, [('name', '=', module)])[0]
78+ module = self.browse(cr, uid, module_id, context=context)
79+ filter_model_ids = [model.id for model in module.filter_model_ids]
80 for mod in obj_mod_data.browse(cr, uid, model_data_ids, context=context):
81- model_ids.append(mod.res_id)
82- models = obj_model.browse(cr, uid, model_ids, context=context)
83- map(lambda x: obj_ids.append(x.id),models)
84- return obj_ids
85+ if not filter_model_ids or mod.res_id in filter_model_ids:
86+ model_ids.append(mod.res_id)
87+ return model_ids
88
89 def get_relation_graph(self, cr, uid, module_name, context=None):
90+<<<<<<< TREE
91 if context is None: context = {}
92+=======
93+ if context is None:
94+ context = {}
95+ result = {}
96+>>>>>>> MERGE-SOURCE
97 object_ids = self._get_module_objects(cr, uid, module_name, context=context)
98 if not object_ids:
99- return {'module_file': False}
100- context.update({'level': 1})
101- dots = self.get_graphical_representation(cr, uid, object_ids, context=context)
102+ return False
103+ module_id = self.search(cr, uid, [('name', '=', module_name)])[0]
104+ module = self.browse(cr, uid, module_id)
105+ context.update({'level': module.level})
106+ dots = self.get_graphical_representation(cr, uid, module_id, object_ids, context=context)
107 # todo: use os.realpath
108 file_path = addons.get_module_resource('base_module_doc_rst')
109 path_png = file_path + "/module.png"
110@@ -111,12 +139,17 @@
111 fp = file(path_dotfile, "w")
112 fp.write(val)
113 fp.close()
114+ fp = file(path_dotfile, "r")
115+ x = fp.read()
116+ fp.close()
117+ result['dot_graph'] = base64.encodestring(x)
118 os.popen('dot -Tpng' +' '+ path_dotfile + ' '+ '-o' +' ' + path_png)
119 fp = file(path_png, "r")
120 x = fp.read()
121 fp.close()
122 os.popen('rm ' + path_dotfile + ' ' + path_png)
123- return {'module_file': base64.encodestring(x)}
124+ result['file_graph'] = base64.encodestring(x)
125+ return result
126
127 module()
128
129
130=== modified file 'base_module_doc_rst/base_module_doc_rst_view.xml'
131--- base_module_doc_rst/base_module_doc_rst_view.xml 2011-01-14 00:11:01 +0000
132+++ base_module_doc_rst/base_module_doc_rst_view.xml 2011-10-05 06:32:31 +0000
133@@ -1,5 +1,6 @@
134 <?xml version="1.0"?>
135 <openerp>
136+<<<<<<< TREE
137 <data>
138
139 <!--
140@@ -22,4 +23,32 @@
141 </record>
142
143 </data>
144+=======
145+ <data>
146+
147+ <!--
148+ Relationshio Graph on Module object
149+ -->
150+
151+ <record model="ir.ui.view" id="view_module_module_graph">
152+ <field name="name">ir.module.module.form.graph</field>
153+ <field name="model">ir.module.module</field>
154+ <field name="inherit_id" ref="base.module_form"/>
155+ <field name="type">form</field>
156+ <field name="arch" type="xml">
157+ <notebook position="inside">
158+ <page string="Relationship Graph">
159+ <separator colspan="4" string="You can filter the models taken into account to generate the graph"/>
160+ <field name="filter_model_ids" colspan="4" nolabel="1"/>
161+ <field name="level"/>
162+ <separator colspan="4" string="You can save this image as .png file"/>
163+ <field name="file_graph" widget="image" nolabel="1" />
164+ <field name="dot_graph"/>
165+ </page>
166+ </notebook>
167+ </field>
168+ </record>
169+
170+ </data>
171+>>>>>>> MERGE-SOURCE
172 </openerp>
173
174=== modified file 'base_module_doc_rst/report/report_proximity_graph.py'
175--- base_module_doc_rst/report/report_proximity_graph.py 2011-04-18 13:21:25 +0000
176+++ base_module_doc_rst/report/report_proximity_graph.py 2011-10-05 06:32:31 +0000
177@@ -48,7 +48,11 @@
178 if id:
179 get_dpend_module(id[0].id)
180 get_dpend_module(module_id)
181+<<<<<<< TREE
182 graph = pydot.Dot(graph_type='digraph',fontsize='10', label="\\nProximity Graph. \\n\\nGray Color-Official Modules, Red Color-Extra Addons Modules, Blue Color-Community Modules, Purple Color-Unknow Modules"
183+=======
184+ graph = pydot.Dot(graph_type='digraph',fontsize='10', label='"\\nProximity Graph. \\n\\nGray Color:Official Modules, Red Color:Extra Addons Modules, Blue Color:Community Modules, Purple Color:Unknow Modules"'
185+>>>>>>> MERGE-SOURCE
186 , center='1')
187 for node in nodes:
188 if node[1] == "official":
189
190=== modified file 'base_module_doc_rst/wizard/generate_relation_graph.py'
191--- base_module_doc_rst/wizard/generate_relation_graph.py 2011-01-14 00:11:01 +0000
192+++ base_module_doc_rst/wizard/generate_relation_graph.py 2011-10-05 06:32:31 +0000
193@@ -33,9 +33,15 @@
194 modules = mod_obj.browse(cr, uid, datas['ids'], context=context)
195 for module in modules:
196 module_data = mod_obj.get_relation_graph(cr, uid, module.name, context=context)
197+<<<<<<< TREE
198 if module_data['module_file']:
199 mod_obj.write(cr, uid, [module.id], {'file_graph': module_data['module_file']}, context=context)
200 return {'type': 'ir.actions.act_window_close'}
201+=======
202+ if module_data:
203+ mod_obj.write(cr, uid, [module.id], module_data, context=context)
204+ return {}
205+>>>>>>> MERGE-SOURCE
206
207 class create_graph(wizard.interface):
208 states = {

Subscribers

People subscribed via source and target branches

to all changes: