diff --git a/base_module_doc_rst/README.rst b/base_module_doc_rst/README.rst new file mode 100644 index 000000000..75519016a --- /dev/null +++ b/base_module_doc_rst/README.rst @@ -0,0 +1,60 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License AGPL-3 + +================================================================================================= +This module generates the Technical Guides of selected modules in Restructured Text format (RST). +================================================================================================= + +Originally developed by OpenERP SA, migrated from the OpenERP version 6.1 to Odoo version 8.0 +by the Odoo Community Association. + + * It uses the Sphinx (http://sphinx.pocoo.org) implementation of RST + * It creates a tarball (.tgz file suffix) containing an index file and one file per module + * Generates Relationship Graph + +It performs its actions only on the modules that are actually installed in the same database +(being available in the module list is not enough). + +Installation +============ + +* The module automatically takes care of its dependencies and is ready for use after the installation + +TODO +======= + * Hide "Relationship Graph" page if module not installed. + * Raise an exception when clicking on "Generate Relationship..." if the module is not installed. + + +Credits +======= + +Contributors +------------ + +* OpenERP SA +* Matjaž Mozetič + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. \ No newline at end of file diff --git a/base_module_doc_rst/__init__.py b/base_module_doc_rst/__init__.py new file mode 100644 index 000000000..b5cfe36f1 --- /dev/null +++ b/base_module_doc_rst/__init__.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +# © 2004-2009 Tiny SPRL (original author) +# +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import base_module_doc_rst +from . import wizard +from . import report diff --git a/base_module_doc_rst/__openerp__.py b/base_module_doc_rst/__openerp__.py new file mode 100644 index 000000000..8e19ae5ba --- /dev/null +++ b/base_module_doc_rst/__openerp__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + "name": "Generate Docs of Modules", + "version": "8.0.1.0.0", + "category": "Tools", + "summary": "Modules Technical Guides in RST and Relationship Graphs", + "website": "https://odoo-community.org/", + "author": "OpenERP SA,Odoo Community Association (OCA)", + "contributors": [ + "OpenERP SA ", + "Matjaž Mozetič ", + ], + "license": "AGPL-3", + "depends": ["base"], + "data": [ + "base_module_doc_rst_view.xml", + "wizard/generate_relation_graph_view.xml", + "wizard/tech_guide_rst_view.xml", + "module_report.xml", + ], + "demo": [], + "installable": True, +} diff --git a/base_module_doc_rst/base_module_doc_rst.py b/base_module_doc_rst/base_module_doc_rst.py new file mode 100644 index 000000000..021a07796 --- /dev/null +++ b/base_module_doc_rst/base_module_doc_rst.py @@ -0,0 +1,180 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import os +import base64 +import openerp.modules.registry +from openerp import models, fields + + +class Module(models.Model): + _inherit = 'ir.module.module' + _description = 'Module With Relationship Graph' + + file_graph = fields.Binary('Relationship Graph') + + def _get_graphical_representation( + self, cr, uid, model_ids, level=1, context=None + ): + obj_model = self.pool.get('ir.model') + if level == 0: + return tuple() + relation = [] + for id in model_ids: + model_data = obj_model.browse(cr, uid, id, context=context) + for field in ( + f for f in model_data.field_id if f.ttype in ( + 'many2many', 'many2one', 'one2many' + ) + ): + relation.append( + ( + model_data.model, + field.name, + field.ttype, + field.relation, + field.field_description + ) + ) + new_model_ids = obj_model.search( + cr, + uid, + [('model', '=', field.relation)], + context=context + ) + if new_model_ids: + model = obj_model.read( + cr, + uid, + new_model_ids, + ['id', 'name'], + context=context + )[0] + relation.extend( + self._get_graphical_representation( + cr, uid, model['id'], level - 1 + ) + ) + return tuple(relation) + + def _get_structure(self, relations, main_element): + res = {} + for rel in relations: + # if we have to display the string along with field name, + # then uncomment the first line n comment the second line + res.setdefault(rel[0], set()).add(rel[1]) + res.setdefault(rel[3], set()) + val = [] + for obj, fieldsx in res.items(): + val.append('"%s" [%s label="{%s|%s}"];' % ( + obj, + obj in + main_element and + 'fillcolor=yellow, style="filled,rounded"' or + "", + obj, + "|".join(["<%s> %s" % (fn, fn) for fn in fieldsx]) + )) + return "\n".join(val) + + def _get_arrow(self, field_type='many2one'): + return { + 'many2one': ( + 'arrowtail="none" arrowhead="normal" color="red" label="m2o"' + ), + 'many2many': ( + 'arrowtail="crow" arrowhead="crow" color="green" label="m2m"' + ), + 'one2many': ( + 'arrowtail="none" arrowhead="crow" color="blue" label="o2m"' + ), + }[field_type] + + def get_graphical_representation(self, cr, uid, model_ids, context=None): + obj_model = self.pool.get('ir.model') + if context is None: + context = {} + res = {} + models = [] + for obj in obj_model.browse(cr, uid, model_ids, context=context): + models.append(obj.model) + relations = set( + self._get_graphical_representation( + cr, uid, model_ids, context.get('level', 1) + ) + ) + res[obj.model] = ( + "digraph G {\nnode [style=rounded, shape=record];\n%s\n%s }" % ( + self._get_structure(relations, models), + ''.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), + ) + ) + return res + + def _get_module_objects(self, cr, uid, module, context=None): + obj_model = self.pool.get('ir.model') + obj_mod_data = self.pool.get('ir.model.data') + obj_ids = [] + model_data_ids = obj_mod_data.search( + cr, uid, + [('module', '=', module), ('model', '=', 'ir.model')], + context=context + ) + model_ids = [] + for mod in obj_mod_data.browse( + cr, uid, model_data_ids, context=context + ): + model_ids.append(mod.res_id) + models = obj_model.browse(cr, uid, model_ids, context=context) + map(lambda x: obj_ids.append(x.id), models) + return obj_ids + + def get_relation_graph(self, cr, uid, module_name, context=None): + if context is None: + context = {} + object_ids = self._get_module_objects( + cr, uid, module_name, context=context + ) + if not object_ids: + return {'module_file': False} + # context.update({'level': 1}) + dots = self.get_graphical_representation( + cr, uid, object_ids, context=context + ) + # todo: use os.realpath + file_path = openerp.modules.module.get_module_path( + 'base_module_doc_rst' + ) + path_png = file_path + "/module.png" + for key, val in dots.items(): + path_dotfile = file_path + "/%s.dot" % (key,) + fp = file(path_dotfile, "w") + fp.write(val) + fp.close() + os.popen( + 'dot -Tpng' + ' ' + path_dotfile + ' ' + '-o' + ' ' + path_png + ) + fp = file(path_png, "r") + x = fp.read() + fp.close() + os.popen('rm ' + path_dotfile + ' ' + path_png) + return {'module_file': base64.encodestring(x)} diff --git a/base_module_doc_rst/base_module_doc_rst_view.xml b/base_module_doc_rst/base_module_doc_rst_view.xml new file mode 100644 index 000000000..2fa4e220d --- /dev/null +++ b/base_module_doc_rst/base_module_doc_rst_view.xml @@ -0,0 +1,25 @@ + + + + + + + + ir.module.module.form.graph + ir.module.module + + form + + + + + + + + + + + + diff --git a/base_module_doc_rst/i18n/base_module_doc_rst.pot b/base_module_doc_rst/i18n/base_module_doc_rst.pot new file mode 100644 index 000000000..d4f226367 --- /dev/null +++ b/base_module_doc_rst/i18n/base_module_doc_rst.pot @@ -0,0 +1,114 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_module_doc_rst +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-17 11:49+0000\n" +"PO-Revision-Date: 2015-09-17 11:49+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Cancel" +msgstr "" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Create Graphs" +msgstr "" + +#. module: base_module_doc_rst +#: model:ir.actions.act_window,name:base_module_doc_rst.wiz_tech_guide_rst +msgid "Create RST Technical Guide2" +msgstr "" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Create Technical Guide in rst format" +msgstr "" + +#. module: base_module_doc_rst +#: field:create.relation.graph,create_uid:0 +#: field:tech.guide.rst,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: base_module_doc_rst +#: field:create.relation.graph,create_date:0 +#: field:tech.guide.rst,create_date:0 +msgid "Created on" +msgstr "" + +#. module: base_module_doc_rst +#: field:tech.guide.rst,rst_file:0 +msgid "File" +msgstr "" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +#: model:ir.actions.act_window,name:base_module_doc_rst.generate_relationship_graph_values +msgid "Generate Relationship Graph" +msgstr "" + +#. module: base_module_doc_rst +#: field:create.relation.graph,id:0 +#: field:tech.guide.rst,id:0 +msgid "ID" +msgstr "" + +#. module: base_module_doc_rst +#: field:create.relation.graph,write_uid:0 +#: field:tech.guide.rst,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: base_module_doc_rst +#: field:create.relation.graph,write_date:0 +#: field:tech.guide.rst,write_date:0 +msgid "Last Updated on" +msgstr "" + +#. module: base_module_doc_rst +#: model:ir.model,name:base_module_doc_rst.model_ir_module_module +msgid "Module" +msgstr "" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Please choose a file where the Technical Guide will be written." +msgstr "" + +#. module: base_module_doc_rst +#: model:ir.actions.report.xml,name:base_module_doc_rst.report_proximity_graph +msgid "Proximity graph" +msgstr "" + +#. module: base_module_doc_rst +#: view:ir.module.module:base_module_doc_rst.view_module_module_graph +#: field:ir.module.module,file_graph:0 +msgid "Relationship Graph" +msgstr "" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Relationship Graphs" +msgstr "" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Technical Guide in rst format" +msgstr "" + +#. module: base_module_doc_rst +#: view:ir.module.module:base_module_doc_rst.view_module_module_graph +msgid "You can save this image as .png file" +msgstr "" + diff --git a/base_module_doc_rst/i18n/it.po b/base_module_doc_rst/i18n/it.po new file mode 100644 index 000000000..fcbc09d24 --- /dev/null +++ b/base_module_doc_rst/i18n/it.po @@ -0,0 +1,125 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_module_doc_rst +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0dev\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-17 13:51+0200\n" +"PO-Revision-Date: 2015-09-17 13:52+0200\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2013-05-29 06:51+0000\n" +"X-Generator: Poedit 1.8.4\n" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Cancel" +msgstr "Cancella" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Create Graphs" +msgstr "Creazione dei grafici" + +#. module: base_module_doc_rst +#: model:ir.actions.act_window,name:base_module_doc_rst.wiz_tech_guide_rst +msgid "Create RST Technical Guide2" +msgstr "Creazione della Guida Tecnica in 'rst'" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Create Technical Guide in rst format" +msgstr "Creazione della Guida Tecnica nel formato 'rst'" + +#. module: base_module_doc_rst +#: field:create.relation.graph,create_uid:0 field:tech.guide.rst,create_uid:0 +msgid "Created by" +msgstr "Creato da" + +#. module: base_module_doc_rst +#: field:create.relation.graph,create_date:0 field:tech.guide.rst,create_date:0 +msgid "Created on" +msgstr "Creato il" + +#. module: base_module_doc_rst +#: field:tech.guide.rst,rst_file:0 +msgid "File" +msgstr "File" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +#: model:ir.actions.act_window,name:base_module_doc_rst.generate_relationship_graph_values +msgid "Generate Relationship Graph" +msgstr "Genera grafici relazioni" + +#. module: base_module_doc_rst +#: field:create.relation.graph,id:0 field:tech.guide.rst,id:0 +msgid "ID" +msgstr "ID" + +#. module: base_module_doc_rst +#: field:create.relation.graph,write_uid:0 field:tech.guide.rst,write_uid:0 +msgid "Last Updated by" +msgstr "Ultimo aggiornamento da" + +#. module: base_module_doc_rst +#: field:create.relation.graph,write_date:0 field:tech.guide.rst,write_date:0 +msgid "Last Updated on" +msgstr "Ultimo aggiornamento il" + +#. module: base_module_doc_rst +#: model:ir.model,name:base_module_doc_rst.model_ir_module_module +msgid "Module" +msgstr "Modulo" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Please choose a file where the Technical Guide will be written." +msgstr "Selezionare un file dove la Guida Tecnica potrebbe essere scritta." + +#. module: base_module_doc_rst +#: model:ir.actions.report.xml,name:base_module_doc_rst.report_proximity_graph +msgid "Proximity graph" +msgstr "Grafico prossimità" + +#. module: base_module_doc_rst +#: view:ir.module.module:base_module_doc_rst.view_module_module_graph +#: field:ir.module.module,file_graph:0 +msgid "Relationship Graph" +msgstr "Grafico relazioni" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Relationship Graphs" +msgstr "Grafico relazioni" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Technical Guide in rst format" +msgstr "Guida tecnica nel formato 'rst'" + +#. module: base_module_doc_rst +#: view:ir.module.module:base_module_doc_rst.view_module_module_graph +msgid "You can save this image as .png file" +msgstr "E' possibile salvare questa immagine come file .PNG" + +#~ msgid "Ok" +#~ msgstr "Ok" + +#~ msgid "(Relationship Graphs generated)" +#~ msgstr "(Grafici relazioni generati)" + +#~ msgid "filename" +#~ msgstr "nome file" + +#~ msgid "file" +#~ msgstr "file" + +#~ msgid "Close" +#~ msgstr "Chiudi" diff --git a/base_module_doc_rst/i18n/sl.po b/base_module_doc_rst/i18n/sl.po new file mode 100644 index 000000000..857a3d9fe --- /dev/null +++ b/base_module_doc_rst/i18n/sl.po @@ -0,0 +1,119 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * base_module_doc_rst +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0dev\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-09-17 13:50+0200\n" +"PO-Revision-Date: 2015-09-17 13:51+0200\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: \n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2013-05-29 06:51+0000\n" +"X-Generator: Poedit 1.8.4\n" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Cancel" +msgstr "Preklic" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Create Graphs" +msgstr "Ustvari grafe" + +#. module: base_module_doc_rst +#: model:ir.actions.act_window,name:base_module_doc_rst.wiz_tech_guide_rst +msgid "Create RST Technical Guide2" +msgstr "Izdelaj RST tehnična navodila" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Create Technical Guide in rst format" +msgstr "Izdelaj tehnična navodila v formatu rst" + +#. module: base_module_doc_rst +#: field:create.relation.graph,create_uid:0 field:tech.guide.rst,create_uid:0 +msgid "Created by" +msgstr "Ustvaril" + +#. module: base_module_doc_rst +#: field:create.relation.graph,create_date:0 field:tech.guide.rst,create_date:0 +msgid "Created on" +msgstr "Ustvarjeno" + +#. module: base_module_doc_rst +#: field:tech.guide.rst,rst_file:0 +msgid "File" +msgstr "Datoteka" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +#: model:ir.actions.act_window,name:base_module_doc_rst.generate_relationship_graph_values +msgid "Generate Relationship Graph" +msgstr "Ustvari relacijski diagram" + +#. module: base_module_doc_rst +#: field:create.relation.graph,id:0 field:tech.guide.rst,id:0 +msgid "ID" +msgstr "ID" + +#. module: base_module_doc_rst +#: field:create.relation.graph,write_uid:0 field:tech.guide.rst,write_uid:0 +msgid "Last Updated by" +msgstr "Zadnjič posodobil" + +#. module: base_module_doc_rst +#: field:create.relation.graph,write_date:0 field:tech.guide.rst,write_date:0 +msgid "Last Updated on" +msgstr "Zadnjič posodobljeno" + +#. module: base_module_doc_rst +#: model:ir.model,name:base_module_doc_rst.model_ir_module_module +msgid "Module" +msgstr "Modul" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Please choose a file where the Technical Guide will be written." +msgstr "Prosimo, izberite datoteko, v katero se bodo zapisala tehnična navodila" + +#. module: base_module_doc_rst +#: model:ir.actions.report.xml,name:base_module_doc_rst.report_proximity_graph +msgid "Proximity graph" +msgstr "Graf bližine" + +#. module: base_module_doc_rst +#: view:ir.module.module:base_module_doc_rst.view_module_module_graph +#: field:ir.module.module,file_graph:0 +msgid "Relationship Graph" +msgstr "Relacijski diagram" + +#. module: base_module_doc_rst +#: view:create.relation.graph:base_module_doc_rst.view_relationship_graph +msgid "Relationship Graphs" +msgstr "Relacijski diagrami" + +#. module: base_module_doc_rst +#: view:tech.guide.rst:base_module_doc_rst.view_technical_guide +msgid "Technical Guide in rst format" +msgstr "Tehnična navodila v rst formatu" + +#. module: base_module_doc_rst +#: view:ir.module.module:base_module_doc_rst.view_module_module_graph +msgid "You can save this image as .png file" +msgstr "To sliko lahko shranite kot .png datoteko." + +#~ msgid "filename" +#~ msgstr "ime datoteke" + +#~ msgid "file" +#~ msgstr "datoteka" + +#~ msgid "Close" +#~ msgstr "Zapri" diff --git a/base_module_doc_rst/module_report.xml b/base_module_doc_rst/module_report.xml new file mode 100644 index 000000000..e3d4e3424 --- /dev/null +++ b/base_module_doc_rst/module_report.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/base_module_doc_rst/report/__init__.py b/base_module_doc_rst/report/__init__.py new file mode 100644 index 000000000..741758c3d --- /dev/null +++ b/base_module_doc_rst/report/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import ir_module_reference_print_graph +from . import report_proximity_graph diff --git a/base_module_doc_rst/report/ir_module_reference_graph.rml b/base_module_doc_rst/report/ir_module_reference_graph.rml new file mode 100644 index 000000000..40f631fc9 --- /dev/null +++ b/base_module_doc_rst/report/ir_module_reference_graph.rml @@ -0,0 +1,270 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Introspection report on objects + + + + + + + + + + + + + + +
+ [[ repeatIn(objects,'module') ]] + + + + Module + + + Name + + + Version + + + Directory + + + Web + + + + + + + [[ module.name ]] + + + [[ module.shortdesc]] + + + [[module.latest_version]] + + + [[ module.name ]] + + + [[ module.website ]] + + + + + + + [[ module.description ]] + + + + Reports : + [[ format(module.reports_by_module) ]] + + + + Menu : + [[ format(module.menus_by_module) ]] + + + + View : + [[ format(module.views_by_module) ]] + + + + + + + Dependencies : + + + + + [[ repeatIn(module.dependencies_id,'dependencies_id') ]] + [[ dependencies_id.name ]] - [[ dependencies_id.state ]] + + + +
+ + + + [[ repeatIn(findobj(module.name) ,'object') ]] + + + + + + + Object: [[ object.model ]] [[ objdoc(object.model) ]] + + + + + [[ repeatIn(objdoc2(object.model) or [], 'sline') ]] + [[ sline ]] + + + +
+ + + +
+
+ [[ repeatIn(findflds(object.model), 'field') ]] + + + + [[ field[0] ]] + + + [[ field[1].get('string', 'Unknown') ]], [[ field[1]['type'] ]] [[field[1].get('required',False) and ', required']] [[field[1].get('readonly',False) and ', readonly']] + [[ field[1].get('help', '') ]] + + + + + + +
+
+ + [[ module.file_graph and setTag('para','image', {'width':'300.0','height':'250.0'}) ]][[ module.file_graph ]] +
+
+
diff --git a/base_module_doc_rst/report/ir_module_reference_graph.sxw b/base_module_doc_rst/report/ir_module_reference_graph.sxw new file mode 100644 index 000000000..77052af5e Binary files /dev/null and b/base_module_doc_rst/report/ir_module_reference_graph.sxw differ diff --git a/base_module_doc_rst/report/ir_module_reference_print_graph.py b/base_module_doc_rst/report/ir_module_reference_print_graph.py new file mode 100644 index 000000000..2f101a629 --- /dev/null +++ b/base_module_doc_rst/report/ir_module_reference_print_graph.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +from openerp.report import report_sxw + + +class IrModuleReferencePrintGraph(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(IrModuleReferencePrintGraph, self).__init__( + cr, uid, name, context=context + ) + self.localcontext.update({ + 'time': time, + 'findobj': self._object_find, + 'objdoc': self._object_doc, + 'objdoc2': self._object_doc2, + 'findflds': self._fields_find, + }) + + def _object_doc(self, obj): + modobj = self.pool.get(obj) + strdocs = modobj.__doc__ + if not strdocs: + return None + else: + strdocs = strdocs.strip().splitlines(True) + res = '' + for stre in strdocs: + if not stre or stre.isspace(): + break + res += stre + return res + + def _object_doc2(self, obj): + modobj = self.pool.get(obj) + strdocs = modobj.__doc__ + if not strdocs: + return None + else: + strdocs = strdocs.strip().splitlines(True) + res = [] + fou = False + for stre in strdocs: + if fou: + res.append(stre.strip()) + elif not stre or stre.isspace(): + fou = True + return res + + def _object_find(self, module): + ids2 = self.pool.get('ir.model.data').search( + self.cr, self.uid, [ + ('module', '=', module), ('model', '=', 'ir.model') + ] + ) + ids = [] + for mod in self.pool.get('ir.model.data').browse( + self.cr, self.uid, ids2 + ): + ids.append(mod.res_id) + modobj = self.pool.get('ir.model') + return modobj.browse(self.cr, self.uid, ids) + + def _fields_find(self, obj): + modobj = self.pool.get(obj) + res = modobj.fields_get(self.cr, self.uid).items() + return res + +report_sxw.report_sxw( + 'report.ir.module.reference.graph', + 'ir.module.module', + 'addons/base_module_doc_rst/report/ir_module_reference_graph.rml', + parser=IrModuleReferencePrintGraph, + header=False +) diff --git a/base_module_doc_rst/report/report_proximity_graph.py b/base_module_doc_rst/report/report_proximity_graph.py new file mode 100644 index 000000000..1fb81556c --- /dev/null +++ b/base_module_doc_rst/report/report_proximity_graph.py @@ -0,0 +1,118 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import os +import pydot + +from openerp import report +from openerp import pooler +from openerp import tools + + +class ReportGraph(report.interface.report_int): + def __init__(self, name, table): + report.interface.report_int.__init__(self, name) + self.table = table + + def get_proximity_graph(self, cr, uid, module_id, context=None): + pool_obj = pooler.get_pool(cr.dbname) + module_obj = pool_obj.get('ir.module.module') + nodes = [('base', 'unknown')] + edges = [] + + def get_depend_module(module_id): + module_record = module_obj.browse( + cr, uid, module_id, context=context + ) + if module_record.name not in nodes: + # Add new field ir.module.module object in server side. + # field name = module_type/ + nodes.append((module_record.name, "unknown")) + if module_record.dependencies_id: + for depen in module_record.dependencies_id: + if (module_record.name, depen.name) not in edges: + edges.append((module_record.name, depen.name)) + if depen.name == "base": + continue + id = module_obj.browse(cr, uid, module_obj.search( + cr, uid, [('name', '=', depen.name)]), context=context + ) + if id: + get_depend_module(id[0].id) + get_depend_module(module_id) + graph = pydot.Dot( + graph_type='digraph', + fontsize='10', + label=""" + Proximity Graph. + Gray Color-Official Modules, + Red Color-Extra Addons Modules, + Blue Color-Community Modules, + Purple Color-Unknow Modules + """, + center='1' + ) + for node in nodes: + if node[1] == "official": + graph.add_node( + pydot.Node( + node[0], style="filled", fillcolor="lightgray" + ) + ) + elif node[1] == "extra_addons": + graph.add_node( + pydot.Node( + node[0], style="filled", fillcolor="red" + ) + ) + elif node[1] == "community": + graph.add_node( + pydot.Node( + node[0], style="filled", fillcolor="#000FFF" + ) + ) + elif node[1] == "unknown": + graph.add_node( + pydot.Node( + node[0], style="filled", fillcolor="purple" + ) + ) + for edge in edges: + graph.add_edge(pydot.Edge(edge[0], edge[1])) + + ps_string = graph.create(prog='dot', format='ps') + if os.name == "nt": + prog = 'ps2pdf.bat' + else: + prog = 'ps2pdf' + + args = (prog, '-', '-') + input, output = tools.exec_command_pipe(*args) + input.write(ps_string) + input.close() + return output.read() + + def create(self, cr, uid, ids, data, context=None): + pdf_string = self.get_proximity_graph( + cr, uid, context.get('active_id') + ) + return (pdf_string, 'pdf') + +ReportGraph('report.proximity.graph', 'ir.module.module') diff --git a/base_module_doc_rst/wizard/__init__.py b/base_module_doc_rst/wizard/__init__.py new file mode 100644 index 000000000..f5c85a654 --- /dev/null +++ b/base_module_doc_rst/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import tech_rst_guide +from . import generate_relation_graph diff --git a/base_module_doc_rst/wizard/generate_relation_graph.py b/base_module_doc_rst/wizard/generate_relation_graph.py new file mode 100644 index 000000000..52c64efc7 --- /dev/null +++ b/base_module_doc_rst/wizard/generate_relation_graph.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm + + +class CreateGraph(orm.TransientModel): + _name = "create.relation.graph" + + def get_graph(self, cr, uid, datas, context=None): + mod_obj = self.pool.get('ir.module.module') + modules = mod_obj.browse( + cr, uid, context['active_ids'], context=context + ) + for module in modules: + module_data = mod_obj.get_relation_graph( + cr, uid, module.name, context=context + ) + if module_data['module_file']: + mod_obj.write( + cr, + uid, + [module.id], + {'file_graph': module_data['module_file']}, + context=context + ) + return {'type': 'ir.actions.act_window_close'} diff --git a/base_module_doc_rst/wizard/generate_relation_graph_view.xml b/base_module_doc_rst/wizard/generate_relation_graph_view.xml new file mode 100644 index 000000000..4712ac2ca --- /dev/null +++ b/base_module_doc_rst/wizard/generate_relation_graph_view.xml @@ -0,0 +1,28 @@ + + + + + + create.relation.graph.form + create.relation.graph + form + +
+ +