Browse Source

[ADD] new module 'module_parent_dependencies'

pull/8/head
Sylvain LE GAL 11 years ago
parent
commit
a976157883
  1. 23
      module_parent_dependencies/__init__.py
  2. 54
      module_parent_dependencies/__openerp__.py
  3. 41
      module_parent_dependencies/i18n/fr.po
  4. 23
      module_parent_dependencies/model/__init__.py
  5. 72
      module_parent_dependencies/model/ir_module_module.py
  6. BIN
      module_parent_dependencies/static/src/img/icon.png
  7. BIN
      module_parent_dependencies/static/src/img/screenshots/dependencies_list.jpg
  8. 24
      module_parent_dependencies/tests/__init__.py
  9. 65
      module_parent_dependencies/tests/test_module_parent_dependencies.py
  10. 40
      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/>.
#
##############################################################################
import model

54
module_parent_dependencies/__openerp__.py

@ -0,0 +1,54 @@
# -*- 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': 'Display the parent dependencies of a module',
'category': 'Tools',
'description': """
Display the parent dependencies of a module
===========================================
Functionality:
--------------
* This module display to the admin user, the possibility to see the list"""
""" of the modules that depends (directly or indirectly) on a module.
Copyright, Authors and Licence:
-------------------------------
* Copyright: 2014, GRAP: Groupement Régional Alimentaire de Proximité;
* Author: Sylvain LE GAL (https://twitter.com/legalsylvain);
* Licence: AGPL-3 (http://www.gnu.org/licenses/);""",
'author': 'GRAP',
'website': 'http://www.grap.coop',
'license': 'AGPL-3',
'depends': [
'base',
],
'data': [
'view/view.xml',
],
'images': [
'static/src/img/screenshots/dependencies_list.jpg'
],
}

41
module_parent_dependencies/i18n/fr.po

@ -0,0 +1,41 @@
# 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-07-09 15:55+0000\n"
"PO-Revision-Date: 2014-07-09 15:55+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_parent_ids:0
msgid "Direct Parent Modules"
msgstr "Modules Parents Directs"
#. module: module_parent_dependencies
#: view:ir.module.module:0
#: field:ir.module.module,all_parent_ids:0
msgid "Direct and Indirect Parent Modules"
msgstr "Modules Parents Directs et Indirectes"
#. 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"

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

72
module_parent_dependencies/model/ir_module_module.py

@ -0,0 +1,72 @@
# -*- 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_parent_ids(
self, cr, uid, ids, field_name, arg, context=None):
res = self._get_direct_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_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_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_parent_ids': fields.function(
_get_direct_parent_ids, type='many2many',
relation='ir.module.module', string='Direct Parent Modules'),
'all_parent_ids': fields.function(
_get_all_parent_ids, type='many2many',
relation='ir.module.module',
string='Direct and Indirect Parent 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 OpenERP
# 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 -*-
##############################################################################
#
# Database Integrity module for OpenERP
# 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 'DataBase Integrity' 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.")

40
module_parent_dependencies/view/view.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ********************************************************************** -->
<!-- odule - Parent Dependencies module for Odoo -->
<!-- Copyright (C) 2014- Today 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/>. -->
<!-- ********************************************************************** -->
<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 Modules" colspan="2"/>
<field name="direct_parent_ids" />
<separator string="Direct and Indirect Parent Modules" colspan="2"/>
<field name="all_parent_ids" />
</page>
</notebook>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save