Browse Source
Merge pull request #8 from legalsylvain/7.0-module_parent_dependencies
Merge pull request #8 from legalsylvain/7.0-module_parent_dependencies
[ADD] new module 'module_parent_dependencies'pull/77/head
Sandy
10 years ago
11 changed files with 376 additions and 0 deletions
-
23module_parent_dependencies/__init__.py
-
56module_parent_dependencies/__openerp__.py
-
45module_parent_dependencies/i18n/fr.po
-
45module_parent_dependencies/i18n/module_parent_dependencies.pot
-
23module_parent_dependencies/model/__init__.py
-
73module_parent_dependencies/model/ir_module_module.py
-
BINmodule_parent_dependencies/static/src/img/icon.png
-
BINmodule_parent_dependencies/static/src/img/screenshots/dependencies_list.jpg
-
24module_parent_dependencies/tests/__init__.py
-
65module_parent_dependencies/tests/test_module_parent_dependencies.py
-
22module_parent_dependencies/view/view.xml
@ -0,0 +1,23 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Module - Parent Dependencies module for Odoo |
|||
# Copyright (C) 2014 GRAP (http://www.grap.coop) |
|||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from . import model |
@ -0,0 +1,56 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Module - Parent Dependencies module for Odoo |
|||
# Copyright (C) 2014 GRAP (http://www.grap.coop) |
|||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
{ |
|||
'name': 'Parent Dependencies of Modules', |
|||
'version': '0.1', |
|||
'summary': "allows to see the list of installed modules dependencies of" |
|||
" a given module, at the full depth of the dependency tree", |
|||
'category': 'Tools', |
|||
'description': """ |
|||
allows to see the list of installed modules dependencies of a given module, |
|||
at the full depth of the dependency tree |
|||
=========================================================================== |
|||
========================================= |
|||
|
|||
Functionality: |
|||
-------------- |
|||
* This module allows to see the list of installed modules dependencies of a |
|||
given module, at the full depth of the dependency tree. |
|||
|
|||
Copyright, Authors and Licence: |
|||
------------------------------- |
|||
* Copyright: 2014, GRAP: Groupement Régional Alimentaire de Proximité; |
|||
* Author: Sylvain LE GAL (https://twitter.com/legalsylvain);""", |
|||
'author': 'GRAP', |
|||
'website': 'http://www.grap.coop', |
|||
'license': 'AGPL-3', |
|||
'depends': [ |
|||
'base', |
|||
], |
|||
'data': [ |
|||
'view/view.xml', |
|||
], |
|||
'images': [ |
|||
'static/src/img/screenshots/dependencies_list.jpg' |
|||
], |
|||
} |
@ -0,0 +1,45 @@ |
|||
# Translation of OpenERP Server. |
|||
# This file contains the translation of the following modules: |
|||
# * module_parent_dependencies |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: OpenERP Server 7.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2014-10-19 20:38+0000\n" |
|||
"PO-Revision-Date: 2014-10-19 20:38+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: module_parent_dependencies |
|||
#: view:ir.module.module:0 |
|||
#: field:ir.module.module,direct_installed_parent_ids:0 |
|||
msgid "Direct Parent Installed Modules" |
|||
msgstr "Modules Parents Directs Installés" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: view:ir.module.module:0 |
|||
msgid "Direct and Indirect Installed Parent Modules" |
|||
msgstr "Modules Parents Directs et Indirects Installés" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: field:ir.module.module,all_installed_parent_ids:0 |
|||
msgid "Direct and Indirect Parent Installed Modules" |
|||
msgstr "Modules Parents Directs et Indirects Installés" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: code:_description:0 |
|||
#: model:ir.model,name:module_parent_dependencies.model_ir_module_module |
|||
#, python-format |
|||
msgid "Module" |
|||
msgstr "Module" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: view:ir.module.module:0 |
|||
msgid "Parent informations" |
|||
msgstr "Informations relatives aux modules parents" |
|||
|
@ -0,0 +1,45 @@ |
|||
# Translation of OpenERP Server. |
|||
# This file contains the translation of the following modules: |
|||
# * module_parent_dependencies |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: OpenERP Server 7.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2014-10-19 20:40+0000\n" |
|||
"PO-Revision-Date: 2014-10-19 20:40+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: module_parent_dependencies |
|||
#: view:ir.module.module:0 |
|||
#: field:ir.module.module,direct_installed_parent_ids:0 |
|||
msgid "Direct Parent Installed Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: view:ir.module.module:0 |
|||
msgid "Direct and Indirect Installed Parent Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: field:ir.module.module,all_installed_parent_ids:0 |
|||
msgid "Direct and Indirect Parent Installed Modules" |
|||
msgstr "" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: code:_description:0 |
|||
#: model:ir.model,name:module_parent_dependencies.model_ir_module_module |
|||
#, python-format |
|||
msgid "Module" |
|||
msgstr "" |
|||
|
|||
#. module: module_parent_dependencies |
|||
#: view:ir.module.module:0 |
|||
msgid "Parent informations" |
|||
msgstr "" |
|||
|
@ -0,0 +1,23 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Module - Parent Dependencies module for Odoo |
|||
# Copyright (C) 2014 GRAP (http://www.grap.coop) |
|||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from . import ir_module_module |
@ -0,0 +1,73 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Module - Parent Dependencies module for Odoo |
|||
# Copyright (C) 2014 GRAP (http://www.grap.coop) |
|||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from openerp.osv.orm import Model |
|||
from openerp.osv import fields |
|||
|
|||
|
|||
class module(Model): |
|||
_inherit = 'ir.module.module' |
|||
|
|||
# Field function Section |
|||
def _get_all_installed_parent_ids( |
|||
self, cr, uid, ids, field_name, arg, context=None): |
|||
res = self._get_direct_installed_parent_ids( |
|||
cr, uid, ids, field_name, arg, context=context) |
|||
for id in ids: |
|||
parent_ids = list(res[id]) |
|||
undirect_parent_ids = self._get_all_installed_parent_ids( |
|||
cr, uid, res[id], field_name, arg, context=context) |
|||
for parent_id in parent_ids: |
|||
res[id] += undirect_parent_ids[parent_id] |
|||
res[id] = list(set(res[id])) |
|||
return res |
|||
|
|||
def _get_direct_installed_parent_ids( |
|||
self, cr, uid, ids, field_name, arg, context=None): |
|||
res = {} |
|||
imd_obj = self.pool['ir.module.module.dependency'] |
|||
for imm in self.browse(cr, uid, ids, context=context): |
|||
imd_ids = imd_obj.search( |
|||
cr, uid, [('name', '=', imm.name)], context=context) |
|||
tmp = imd_obj.read( |
|||
cr, uid, imd_ids, ['module_id'], context=context) |
|||
imm_ids = [x['module_id'][0] for x in tmp] |
|||
# Select only non uninstalled module |
|||
imm_ids = self.search( |
|||
cr, uid, [ |
|||
('id', 'in', imm_ids), |
|||
('state', 'not in', ['uninstalled', 'uninstallable'])], |
|||
context=context) |
|||
res[imm.id] = imm_ids |
|||
return res |
|||
|
|||
# Column Section |
|||
_columns = { |
|||
'direct_installed_parent_ids': fields.function( |
|||
_get_direct_installed_parent_ids, type='many2many', |
|||
relation='ir.module.module', |
|||
string='Direct Parent Installed Modules'), |
|||
'all_installed_parent_ids': fields.function( |
|||
_get_all_installed_parent_ids, type='many2many', |
|||
relation='ir.module.module', |
|||
string='Direct and Indirect Parent Installed Modules'), |
|||
} |
After Width: 128 | Height: 128 | Size: 2.1 KiB |
After Width: 1161 | Height: 667 | Size: 81 KiB |
@ -0,0 +1,24 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Module - Parent Dependencies module for Odoo |
|||
# Copyright (C) 2014 GRAP (http://www.grap.coop) |
|||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
|
|||
from . import test_module_parent_dependencies |
@ -0,0 +1,65 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Module - Parent Dependencies module for Odoo |
|||
# Copyright (C) 2014 GRAP (http://www.grap.coop) |
|||
# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
|||
# |
|||
# 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 <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestmoduleParentDependencies(TransactionCase): |
|||
"""Tests for 'Parent Dependencies module' Module""" |
|||
|
|||
def setUp(self): |
|||
super(TestmoduleParentDependencies, self).setUp() |
|||
self.im_obj = self.registry('ir.module.module') |
|||
|
|||
# Test Section |
|||
def test_01_direct_parent(self): |
|||
"""Test if the compute of the field direct_parent_ids is correct.""" |
|||
cr, uid = self.cr, self.uid |
|||
# compute expected values |
|||
cr.execute("""SELECT module_id |
|||
FROM ir_module_module_dependency immd |
|||
INNER JOIN ir_module_module imm on imm.id = immd.module_id |
|||
WHERE immd.name='base' |
|||
AND imm.state not in ('uninstalled', 'uninstallable')""") |
|||
expected_parent_ids = [x[0] for x in cr.fetchall()] |
|||
|
|||
# Get values |
|||
base_id = self.im_obj.search(cr, uid, [('name', '=', 'base')]) |
|||
tmp = self.im_obj.browse( |
|||
cr, uid, base_id) |
|||
parent_ids = [x.id for x in tmp[0].direct_parent_ids] |
|||
|
|||
self.assertEqual( |
|||
sorted(parent_ids), sorted(expected_parent_ids), |
|||
"Incorrect computation of 'direct_parent_id's fields.") |
|||
|
|||
def test_02_all_parent(self): |
|||
"""Test if the compute of the field direct_parent_ids doesn't crash.""" |
|||
cr, uid = self.cr, self.uid |
|||
base_id = self.im_obj.search(cr, uid, [('name', '=', 'base')]) |
|||
tmp = self.im_obj.browse( |
|||
cr, uid, base_id) |
|||
parent_ids = [x.id for x in tmp[0].all_parent_ids] |
|||
|
|||
self.assertNotEqual( |
|||
sorted(parent_ids), [], |
|||
"Incorrect computation of 'direct_parent_id's fields.") |
@ -0,0 +1,22 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="view_ir_module_module_form" model="ir.ui.view"> |
|||
<field name="name">ir.module.module.form</field> |
|||
<field name="model">ir.module.module</field> |
|||
<field name="inherit_id" ref="base.module_form" /> |
|||
<field name="arch" type="xml"> |
|||
<notebook position="inside"> |
|||
<page string="Parent informations"> |
|||
<separator string="Direct Parent Installed Modules" colspan="2"/> |
|||
<field name="direct_installed_parent_ids" /> |
|||
<separator string="Direct and Indirect Installed Parent Modules" colspan="2"/> |
|||
<field name="all_installed_parent_ids" /> |
|||
</page> |
|||
</notebook> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue