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
=== modified file 'base_module_doc_rst/base_module_doc_rst.py'
--- base_module_doc_rst/base_module_doc_rst.py 2011-01-17 09:36:23 +0000
+++ base_module_doc_rst/base_module_doc_rst.py 2011-10-05 06:32:31 +0000
@@ -31,21 +31,36 @@
31 _description = 'Module With Relationship Graph'31 _description = 'Module With Relationship Graph'
32 _columns = {32 _columns = {
33 'file_graph': fields.binary('Relationship Graph'),33 'file_graph': fields.binary('Relationship Graph'),
34 'level': fields.integer('Level', help="""Number of times a model is processed
35when it is in relation with another model."""),
36 'filter_model_ids': fields.many2many('ir.model', 'module_filter_model_rel', 'module_id', 'model_id', 'Filter models'),
37 'dot_graph': fields.binary('Graph (DOT file)'),
34 }38 }
3539
40<<<<<<< TREE
36 def _get_graphical_representation(self, cr, uid, model_ids, level=1, context=None):41 def _get_graphical_representation(self, cr, uid, model_ids, level=1, context=None):
42=======
43 _defaults = {
44 'level': 1
45 }
46
47 def _get_graphical_representation(self, cr, uid, module_id, model_ids, level=1, context={}):
48>>>>>>> MERGE-SOURCE
37 obj_model = self.pool.get('ir.model')49 obj_model = self.pool.get('ir.model')
38 if level == 0:50 if level == 0:
39 return tuple()51 return tuple()
40 relation = []52 relation = []
53 module = self.browse(cr, uid, module_id, context=context)
54 filter_models = [model.model for model in module.filter_model_ids]
41 for id in model_ids:55 for id in model_ids:
42 model_data = obj_model.browse(cr, uid, id, context=context)56 model_data = obj_model.browse(cr, uid, id, context=context)
43 for field in (f for f in model_data.field_id if f.ttype in ('many2many', 'many2one', 'one2many')):57 for field in (f for f in model_data.field_id if f.ttype in ('many2many', 'many2one', 'one2many')):
44 relation.append((model_data.model, field.name, field.ttype, field.relation, field.field_description))58 if not filter_models or field.relation in filter_models:
45 new_model_ids = obj_model.search(cr, uid, [('model', '=', field.relation)], context=context)59 relation.append((model_data.model, field.name, field.ttype, field.relation, field.field_description))
46 if new_model_ids:60 new_model_ids = obj_model.search(cr, uid, [('model', '=', field.relation)], context=context)
47 model = obj_model.read(cr, uid, new_model_ids, ['id', 'name'], context=context)[0]61 if new_model_ids:
48 relation.extend(self._get_graphical_representation(cr, uid, model['id'], level - 1))62 model = obj_model.read(cr, uid, new_model_ids, ['id', 'name'], context=context)[0]
63 relation.extend(self._get_graphical_representation(cr, uid, module_id, [model['id']], level - 1))
49 return tuple(relation)64 return tuple(relation)
5065
51 def _get_structure(self, relations, main_element):66 def _get_structure(self, relations, main_element):
@@ -69,7 +84,7 @@
69 'one2many': 'arrowtail="none" arrowhead="crow" color="blue" label="o2m"',84 'one2many': 'arrowtail="none" arrowhead="crow" color="blue" label="o2m"',
70 }[field_type]85 }[field_type]
7186
72 def get_graphical_representation(self, cr, uid, model_ids, context=None):87 def get_graphical_representation(self, cr, uid, id, model_ids, context=None):
73 obj_model = self.pool.get('ir.model')88 obj_model = self.pool.get('ir.model')
74 if context is None:89 if context is None:
75 context = {}90 context = {}
@@ -77,32 +92,45 @@
77 models = []92 models = []
78 for obj in obj_model.browse(cr, uid, model_ids, context=context):93 for obj in obj_model.browse(cr, uid, model_ids, context=context):
79 models.append(obj.model)94 models.append(obj.model)
80 relations = set(self._get_graphical_representation(cr, uid, model_ids, context.get('level', 1)))95 relations = set(self._get_graphical_representation(cr, uid, id, model_ids, context.get('level', 1)))
81 res[obj.model] = "digraph G {\nnode [style=rounded, shape=record];\n%s\n%s }" % (96 res[obj.model] = "digraph G {\nnode [style=rounded, shape=record];\n%s\n%s }" % (
82 self._get_structure(relations, models),97 self._get_structure(relations, models),
83 ''.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),98 ''.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),
84 )99 )
85 return res100 return res
86101
102<<<<<<< TREE
87 def _get_module_objects(self, cr, uid, module, context=None):103 def _get_module_objects(self, cr, uid, module, context=None):
88 obj_model = self.pool.get('ir.model')104 obj_model = self.pool.get('ir.model')
105=======
106 def _get_module_objects(self, cr, uid, module, context={}):
107>>>>>>> MERGE-SOURCE
89 obj_mod_data = self.pool.get('ir.model.data')108 obj_mod_data = self.pool.get('ir.model.data')
90 obj_ids = []
91 model_data_ids = obj_mod_data.search(cr, uid, [('module', '=', module), ('model', '=', 'ir.model')], context=context)109 model_data_ids = obj_mod_data.search(cr, uid, [('module', '=', module), ('model', '=', 'ir.model')], context=context)
92 model_ids = []110 model_ids = []
111 module_id = self.search(cr, uid, [('name', '=', module)])[0]
112 module = self.browse(cr, uid, module_id, context=context)
113 filter_model_ids = [model.id for model in module.filter_model_ids]
93 for mod in obj_mod_data.browse(cr, uid, model_data_ids, context=context):114 for mod in obj_mod_data.browse(cr, uid, model_data_ids, context=context):
94 model_ids.append(mod.res_id)115 if not filter_model_ids or mod.res_id in filter_model_ids:
95 models = obj_model.browse(cr, uid, model_ids, context=context)116 model_ids.append(mod.res_id)
96 map(lambda x: obj_ids.append(x.id),models)117 return model_ids
97 return obj_ids
98118
99 def get_relation_graph(self, cr, uid, module_name, context=None):119 def get_relation_graph(self, cr, uid, module_name, context=None):
120<<<<<<< TREE
100 if context is None: context = {}121 if context is None: context = {}
122=======
123 if context is None:
124 context = {}
125 result = {}
126>>>>>>> MERGE-SOURCE
101 object_ids = self._get_module_objects(cr, uid, module_name, context=context)127 object_ids = self._get_module_objects(cr, uid, module_name, context=context)
102 if not object_ids:128 if not object_ids:
103 return {'module_file': False}129 return False
104 context.update({'level': 1})130 module_id = self.search(cr, uid, [('name', '=', module_name)])[0]
105 dots = self.get_graphical_representation(cr, uid, object_ids, context=context)131 module = self.browse(cr, uid, module_id)
132 context.update({'level': module.level})
133 dots = self.get_graphical_representation(cr, uid, module_id, object_ids, context=context)
106 # todo: use os.realpath134 # todo: use os.realpath
107 file_path = addons.get_module_resource('base_module_doc_rst')135 file_path = addons.get_module_resource('base_module_doc_rst')
108 path_png = file_path + "/module.png"136 path_png = file_path + "/module.png"
@@ -111,12 +139,17 @@
111 fp = file(path_dotfile, "w")139 fp = file(path_dotfile, "w")
112 fp.write(val)140 fp.write(val)
113 fp.close()141 fp.close()
142 fp = file(path_dotfile, "r")
143 x = fp.read()
144 fp.close()
145 result['dot_graph'] = base64.encodestring(x)
114 os.popen('dot -Tpng' +' '+ path_dotfile + ' '+ '-o' +' ' + path_png)146 os.popen('dot -Tpng' +' '+ path_dotfile + ' '+ '-o' +' ' + path_png)
115 fp = file(path_png, "r")147 fp = file(path_png, "r")
116 x = fp.read()148 x = fp.read()
117 fp.close()149 fp.close()
118 os.popen('rm ' + path_dotfile + ' ' + path_png)150 os.popen('rm ' + path_dotfile + ' ' + path_png)
119 return {'module_file': base64.encodestring(x)}151 result['file_graph'] = base64.encodestring(x)
152 return result
120153
121module()154module()
122155
123156
=== modified file 'base_module_doc_rst/base_module_doc_rst_view.xml'
--- base_module_doc_rst/base_module_doc_rst_view.xml 2011-01-14 00:11:01 +0000
+++ base_module_doc_rst/base_module_doc_rst_view.xml 2011-10-05 06:32:31 +0000
@@ -1,5 +1,6 @@
1<?xml version="1.0"?>1<?xml version="1.0"?>
2<openerp>2<openerp>
3<<<<<<< TREE
3 <data>4 <data>
45
5 <!--6 <!--
@@ -22,4 +23,32 @@
22 </record>23 </record>
2324
24 </data>25 </data>
26=======
27 <data>
28
29 <!--
30 Relationshio Graph on Module object
31 -->
32
33 <record model="ir.ui.view" id="view_module_module_graph">
34 <field name="name">ir.module.module.form.graph</field>
35 <field name="model">ir.module.module</field>
36 <field name="inherit_id" ref="base.module_form"/>
37 <field name="type">form</field>
38 <field name="arch" type="xml">
39 <notebook position="inside">
40 <page string="Relationship Graph">
41 <separator colspan="4" string="You can filter the models taken into account to generate the graph"/>
42 <field name="filter_model_ids" colspan="4" nolabel="1"/>
43 <field name="level"/>
44 <separator colspan="4" string="You can save this image as .png file"/>
45 <field name="file_graph" widget="image" nolabel="1" />
46 <field name="dot_graph"/>
47 </page>
48 </notebook>
49 </field>
50 </record>
51
52 </data>
53>>>>>>> MERGE-SOURCE
25</openerp>54</openerp>
2655
=== modified file 'base_module_doc_rst/report/report_proximity_graph.py'
--- base_module_doc_rst/report/report_proximity_graph.py 2011-04-18 13:21:25 +0000
+++ base_module_doc_rst/report/report_proximity_graph.py 2011-10-05 06:32:31 +0000
@@ -48,7 +48,11 @@
48 if id:48 if id:
49 get_dpend_module(id[0].id)49 get_dpend_module(id[0].id)
50 get_dpend_module(module_id)50 get_dpend_module(module_id)
51<<<<<<< TREE
51 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"52 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"
53=======
54 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"'
55>>>>>>> MERGE-SOURCE
52 , center='1')56 , center='1')
53 for node in nodes:57 for node in nodes:
54 if node[1] == "official":58 if node[1] == "official":
5559
=== modified file 'base_module_doc_rst/wizard/generate_relation_graph.py'
--- base_module_doc_rst/wizard/generate_relation_graph.py 2011-01-14 00:11:01 +0000
+++ base_module_doc_rst/wizard/generate_relation_graph.py 2011-10-05 06:32:31 +0000
@@ -33,9 +33,15 @@
33 modules = mod_obj.browse(cr, uid, datas['ids'], context=context)33 modules = mod_obj.browse(cr, uid, datas['ids'], context=context)
34 for module in modules:34 for module in modules:
35 module_data = mod_obj.get_relation_graph(cr, uid, module.name, context=context)35 module_data = mod_obj.get_relation_graph(cr, uid, module.name, context=context)
36<<<<<<< TREE
36 if module_data['module_file']:37 if module_data['module_file']:
37 mod_obj.write(cr, uid, [module.id], {'file_graph': module_data['module_file']}, context=context)38 mod_obj.write(cr, uid, [module.id], {'file_graph': module_data['module_file']}, context=context)
38 return {'type': 'ir.actions.act_window_close'}39 return {'type': 'ir.actions.act_window_close'}
40=======
41 if module_data:
42 mod_obj.write(cr, uid, [module.id], module_data, context=context)
43 return {}
44>>>>>>> MERGE-SOURCE
3945
40class create_graph(wizard.interface):46class create_graph(wizard.interface):
41 states = {47 states = {

Subscribers

People subscribed via source and target branches

to all changes: