Browse Source

Merge pull request #8 from legalsylvain/7.0-module_parent_dependencies

[ADD] new module 'module_parent_dependencies'
pull/77/head
Sandy 10 years ago
parent
commit
1b7346d923
  1. 23
      module_parent_dependencies/__init__.py
  2. 56
      module_parent_dependencies/__openerp__.py
  3. 45
      module_parent_dependencies/i18n/fr.po
  4. 45
      module_parent_dependencies/i18n/module_parent_dependencies.pot
  5. 23
      module_parent_dependencies/model/__init__.py
  6. 73
      module_parent_dependencies/model/ir_module_module.py
  7. BIN
      module_parent_dependencies/static/src/img/icon.png
  8. BIN
      module_parent_dependencies/static/src/img/screenshots/dependencies_list.jpg
  9. 24
      module_parent_dependencies/tests/__init__.py
  10. 65
      module_parent_dependencies/tests/test_module_parent_dependencies.py
  11. 22
      module_parent_dependencies/view/view.xml

23
module_parent_dependencies/__init__.py

@ -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

56
module_parent_dependencies/__openerp__.py

@ -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'
],
}

45
module_parent_dependencies/i18n/fr.po

@ -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"

45
module_parent_dependencies/i18n/module_parent_dependencies.pot

@ -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 ""

23
module_parent_dependencies/model/__init__.py

@ -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

73
module_parent_dependencies/model/ir_module_module.py

@ -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'),
}

BIN
module_parent_dependencies/static/src/img/icon.png

After

Width: 128  |  Height: 128  |  Size: 2.1 KiB

BIN
module_parent_dependencies/static/src/img/screenshots/dependencies_list.jpg

After

Width: 1161  |  Height: 667  |  Size: 81 KiB

24
module_parent_dependencies/tests/__init__.py

@ -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

65
module_parent_dependencies/tests/test_module_parent_dependencies.py

@ -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.")

22
module_parent_dependencies/view/view.xml

@ -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>
Loading…
Cancel
Save