Merge lp:~sylvain-legal/server-env-tools/7.0-module_parent_dependencies into lp:server-env-tools
- 7.0-module_parent_dependencies
- Merge into github-7.0
Proposed by
Sylvain LE GAL (GRAP)
Status: | Work in progress |
---|---|
Proposed branch: | lp:~sylvain-legal/server-env-tools/7.0-module_parent_dependencies |
Merge into: | lp:server-env-tools |
Diff against target: |
394 lines (+342/-0) 8 files modified
module_parent_dependencies/__init__.py (+23/-0) module_parent_dependencies/__openerp__.py (+54/-0) module_parent_dependencies/i18n/fr.po (+41/-0) module_parent_dependencies/model/__init__.py (+23/-0) module_parent_dependencies/model/ir_module_module.py (+72/-0) module_parent_dependencies/tests/__init__.py (+24/-0) module_parent_dependencies/tests/test_module_parent_dependencies.py (+65/-0) module_parent_dependencies/view/view.xml (+40/-0) |
To merge this branch: | bzr merge lp:~sylvain-legal/server-env-tools/7.0-module_parent_dependencies |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sylvain LE GAL (GRAP) (community) | Disapprove | ||
Server Environment And Tools Core Editors | Pending | ||
Review via email: mp+226162@code.launchpad.net |
Commit message
Description of the change
Add a module 'module_
Flake8: OK;
Coverage: 100%;
To post a comment you must log in.
Revision history for this message
Sylvain LE GAL (GRAP) (sylvain-legal) wrote : | # |
review:
Disapprove
Unmerged revisions
- 83. By Sylvain LE GAL (GRAP)
-
[ADD] New module 'module_
parent_ dependencies' to see the parent modules of a target module;
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'module_parent_dependencies' |
2 | === added file 'module_parent_dependencies/__init__.py' |
3 | --- module_parent_dependencies/__init__.py 1970-01-01 00:00:00 +0000 |
4 | +++ module_parent_dependencies/__init__.py 2014-07-09 16:10:31 +0000 |
5 | @@ -0,0 +1,23 @@ |
6 | +# -*- encoding: utf-8 -*- |
7 | +############################################################################## |
8 | +# |
9 | +# Module - Parent Dependencies module for Odoo |
10 | +# Copyright (C) 2014 GRAP (http://www.grap.coop) |
11 | +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
12 | +# |
13 | +# This program is free software: you can redistribute it and/or modify |
14 | +# it under the terms of the GNU Affero General Public License as |
15 | +# published by the Free Software Foundation, either version 3 of the |
16 | +# License, or (at your option) any later version. |
17 | +# |
18 | +# This program is distributed in the hope that it will be useful, |
19 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | +# GNU Affero General Public License for more details. |
22 | +# |
23 | +# You should have received a copy of the GNU Affero General Public License |
24 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
25 | +# |
26 | +############################################################################## |
27 | + |
28 | +import model |
29 | |
30 | === added file 'module_parent_dependencies/__openerp__.py' |
31 | --- module_parent_dependencies/__openerp__.py 1970-01-01 00:00:00 +0000 |
32 | +++ module_parent_dependencies/__openerp__.py 2014-07-09 16:10:31 +0000 |
33 | @@ -0,0 +1,54 @@ |
34 | +# -*- encoding: utf-8 -*- |
35 | +############################################################################## |
36 | +# |
37 | +# Module - Parent Dependencies module for Odoo |
38 | +# Copyright (C) 2014 GRAP (http://www.grap.coop) |
39 | +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
40 | +# |
41 | +# This program is free software: you can redistribute it and/or modify |
42 | +# it under the terms of the GNU Affero General Public License as |
43 | +# published by the Free Software Foundation, either version 3 of the |
44 | +# License, or (at your option) any later version. |
45 | +# |
46 | +# This program is distributed in the hope that it will be useful, |
47 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
48 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
49 | +# GNU Affero General Public License for more details. |
50 | +# |
51 | +# You should have received a copy of the GNU Affero General Public License |
52 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
53 | +# |
54 | +############################################################################## |
55 | + |
56 | +{ |
57 | + 'name': 'Parent Dependencies of Modules', |
58 | + 'version': '0.1', |
59 | + 'summary': 'Display the parent dependencies of a module', |
60 | + 'category': 'Tools', |
61 | + 'description': """ |
62 | +Display the parent dependencies of a module |
63 | +=========================================== |
64 | + |
65 | +Functionality: |
66 | +-------------- |
67 | + * This module display to the admin user, the possibility to see the list""" |
68 | + """ of the modules that depends (directly or indirectly) on a module. |
69 | + |
70 | +Copyright, Authors and Licence: |
71 | +------------------------------- |
72 | + * Copyright: 2014, GRAP: Groupement Régional Alimentaire de Proximité; |
73 | + * Author: Sylvain LE GAL (https://twitter.com/legalsylvain); |
74 | + * Licence: AGPL-3 (http://www.gnu.org/licenses/);""", |
75 | + 'author': 'GRAP', |
76 | + 'website': 'http://www.grap.coop', |
77 | + 'license': 'AGPL-3', |
78 | + 'depends': [ |
79 | + 'base', |
80 | + ], |
81 | + 'data': [ |
82 | + 'view/view.xml', |
83 | + ], |
84 | + 'images': [ |
85 | + 'static/src/img/screenshots/dependencies_list.jpg' |
86 | + ], |
87 | +} |
88 | |
89 | === added directory 'module_parent_dependencies/i18n' |
90 | === added file 'module_parent_dependencies/i18n/fr.po' |
91 | --- module_parent_dependencies/i18n/fr.po 1970-01-01 00:00:00 +0000 |
92 | +++ module_parent_dependencies/i18n/fr.po 2014-07-09 16:10:31 +0000 |
93 | @@ -0,0 +1,41 @@ |
94 | +# Translation of OpenERP Server. |
95 | +# This file contains the translation of the following modules: |
96 | +# * module_parent_dependencies |
97 | +# |
98 | +msgid "" |
99 | +msgstr "" |
100 | +"Project-Id-Version: OpenERP Server 7.0\n" |
101 | +"Report-Msgid-Bugs-To: \n" |
102 | +"POT-Creation-Date: 2014-07-09 15:55+0000\n" |
103 | +"PO-Revision-Date: 2014-07-09 15:55+0000\n" |
104 | +"Last-Translator: <>\n" |
105 | +"Language-Team: \n" |
106 | +"MIME-Version: 1.0\n" |
107 | +"Content-Type: text/plain; charset=UTF-8\n" |
108 | +"Content-Transfer-Encoding: \n" |
109 | +"Plural-Forms: \n" |
110 | + |
111 | +#. module: module_parent_dependencies |
112 | +#: view:ir.module.module:0 |
113 | +#: field:ir.module.module,direct_parent_ids:0 |
114 | +msgid "Direct Parent Modules" |
115 | +msgstr "Modules Parents Directs" |
116 | + |
117 | +#. module: module_parent_dependencies |
118 | +#: view:ir.module.module:0 |
119 | +#: field:ir.module.module,all_parent_ids:0 |
120 | +msgid "Direct and Indirect Parent Modules" |
121 | +msgstr "Modules Parents Directs et Indirectes" |
122 | + |
123 | +#. module: module_parent_dependencies |
124 | +#: code:_description:0 |
125 | +#: model:ir.model,name:module_parent_dependencies.model_ir_module_module |
126 | +#, python-format |
127 | +msgid "Module" |
128 | +msgstr "Module" |
129 | + |
130 | +#. module: module_parent_dependencies |
131 | +#: view:ir.module.module:0 |
132 | +msgid "Parent informations" |
133 | +msgstr "Informations relatives aux modules parents" |
134 | + |
135 | |
136 | === added directory 'module_parent_dependencies/model' |
137 | === added file 'module_parent_dependencies/model/__init__.py' |
138 | --- module_parent_dependencies/model/__init__.py 1970-01-01 00:00:00 +0000 |
139 | +++ module_parent_dependencies/model/__init__.py 2014-07-09 16:10:31 +0000 |
140 | @@ -0,0 +1,23 @@ |
141 | +# -*- encoding: utf-8 -*- |
142 | +############################################################################## |
143 | +# |
144 | +# Module - Parent Dependencies module for Odoo |
145 | +# Copyright (C) 2014 GRAP (http://www.grap.coop) |
146 | +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
147 | +# |
148 | +# This program is free software: you can redistribute it and/or modify |
149 | +# it under the terms of the GNU Affero General Public License as |
150 | +# published by the Free Software Foundation, either version 3 of the |
151 | +# License, or (at your option) any later version. |
152 | +# |
153 | +# This program is distributed in the hope that it will be useful, |
154 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
155 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
156 | +# GNU Affero General Public License for more details. |
157 | +# |
158 | +# You should have received a copy of the GNU Affero General Public License |
159 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
160 | +# |
161 | +############################################################################## |
162 | + |
163 | +from . import ir_module_module |
164 | |
165 | === added file 'module_parent_dependencies/model/ir_module_module.py' |
166 | --- module_parent_dependencies/model/ir_module_module.py 1970-01-01 00:00:00 +0000 |
167 | +++ module_parent_dependencies/model/ir_module_module.py 2014-07-09 16:10:31 +0000 |
168 | @@ -0,0 +1,72 @@ |
169 | +# -*- encoding: utf-8 -*- |
170 | +############################################################################## |
171 | +# |
172 | +# Module - Parent Dependencies module for Odoo |
173 | +# Copyright (C) 2014 GRAP (http://www.grap.coop) |
174 | +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
175 | +# |
176 | +# This program is free software: you can redistribute it and/or modify |
177 | +# it under the terms of the GNU Affero General Public License as |
178 | +# published by the Free Software Foundation, either version 3 of the |
179 | +# License, or (at your option) any later version. |
180 | +# |
181 | +# This program is distributed in the hope that it will be useful, |
182 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
183 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
184 | +# GNU Affero General Public License for more details. |
185 | +# |
186 | +# You should have received a copy of the GNU Affero General Public License |
187 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
188 | +# |
189 | +############################################################################## |
190 | + |
191 | +from openerp.osv.orm import Model |
192 | +from openerp.osv import fields |
193 | + |
194 | + |
195 | +class module(Model): |
196 | + _inherit = 'ir.module.module' |
197 | + |
198 | + # Field function Section |
199 | + def _get_all_parent_ids( |
200 | + self, cr, uid, ids, field_name, arg, context=None): |
201 | + res = self._get_direct_parent_ids( |
202 | + cr, uid, ids, field_name, arg, context=context) |
203 | + for id in ids: |
204 | + parent_ids = list(res[id]) |
205 | + undirect_parent_ids = self._get_all_parent_ids( |
206 | + cr, uid, res[id], field_name, arg, context=context) |
207 | + for parent_id in parent_ids: |
208 | + res[id] += undirect_parent_ids[parent_id] |
209 | + res[id] = list(set(res[id])) |
210 | + return res |
211 | + |
212 | + def _get_direct_parent_ids( |
213 | + self, cr, uid, ids, field_name, arg, context=None): |
214 | + res = {} |
215 | + imd_obj = self.pool['ir.module.module.dependency'] |
216 | + for imm in self.browse(cr, uid, ids, context=context): |
217 | + imd_ids = imd_obj.search( |
218 | + cr, uid, [('name', '=', imm.name)], context=context) |
219 | + tmp = imd_obj.read( |
220 | + cr, uid, imd_ids, ['module_id'], context=context) |
221 | + imm_ids = [x['module_id'][0] for x in tmp] |
222 | + # Select only non uninstalled module |
223 | + imm_ids = self.search( |
224 | + cr, uid, [ |
225 | + ('id', 'in', imm_ids), |
226 | + ('state', 'not in', ['uninstalled', 'uninstallable'])], |
227 | + context=context) |
228 | + res[imm.id] = imm_ids |
229 | + return res |
230 | + |
231 | + # Column Section |
232 | + _columns = { |
233 | + 'direct_parent_ids': fields.function( |
234 | + _get_direct_parent_ids, type='many2many', |
235 | + relation='ir.module.module', string='Direct Parent Modules'), |
236 | + 'all_parent_ids': fields.function( |
237 | + _get_all_parent_ids, type='many2many', |
238 | + relation='ir.module.module', |
239 | + string='Direct and Indirect Parent Modules'), |
240 | + } |
241 | |
242 | === added directory 'module_parent_dependencies/static' |
243 | === added directory 'module_parent_dependencies/static/src' |
244 | === added directory 'module_parent_dependencies/static/src/img' |
245 | === added file 'module_parent_dependencies/static/src/img/icon.png' |
246 | Binary files module_parent_dependencies/static/src/img/icon.png 1970-01-01 00:00:00 +0000 and module_parent_dependencies/static/src/img/icon.png 2014-07-09 16:10:31 +0000 differ |
247 | === added directory 'module_parent_dependencies/static/src/img/screenshots' |
248 | === added file 'module_parent_dependencies/static/src/img/screenshots/dependencies_list.jpg' |
249 | Binary files module_parent_dependencies/static/src/img/screenshots/dependencies_list.jpg 1970-01-01 00:00:00 +0000 and module_parent_dependencies/static/src/img/screenshots/dependencies_list.jpg 2014-07-09 16:10:31 +0000 differ |
250 | === added directory 'module_parent_dependencies/tests' |
251 | === added file 'module_parent_dependencies/tests/__init__.py' |
252 | --- module_parent_dependencies/tests/__init__.py 1970-01-01 00:00:00 +0000 |
253 | +++ module_parent_dependencies/tests/__init__.py 2014-07-09 16:10:31 +0000 |
254 | @@ -0,0 +1,24 @@ |
255 | +# -*- encoding: utf-8 -*- |
256 | +############################################################################## |
257 | +# |
258 | +# Module - Parent Dependencies module for OpenERP |
259 | +# Copyright (C) 2014 GRAP (http://www.grap.coop) |
260 | +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
261 | +# |
262 | +# This program is free software: you can redistribute it and/or modify |
263 | +# it under the terms of the GNU Affero General Public License as |
264 | +# published by the Free Software Foundation, either version 3 of the |
265 | +# License, or (at your option) any later version. |
266 | +# |
267 | +# This program is distributed in the hope that it will be useful, |
268 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
269 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
270 | +# GNU Affero General Public License for more details. |
271 | +# |
272 | +# You should have received a copy of the GNU Affero General Public License |
273 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
274 | +# |
275 | +############################################################################## |
276 | + |
277 | + |
278 | +from . import test_module_parent_dependencies |
279 | |
280 | === added file 'module_parent_dependencies/tests/test_module_parent_dependencies.py' |
281 | --- module_parent_dependencies/tests/test_module_parent_dependencies.py 1970-01-01 00:00:00 +0000 |
282 | +++ module_parent_dependencies/tests/test_module_parent_dependencies.py 2014-07-09 16:10:31 +0000 |
283 | @@ -0,0 +1,65 @@ |
284 | +# -*- encoding: utf-8 -*- |
285 | +############################################################################## |
286 | +# |
287 | +# Database Integrity module for OpenERP |
288 | +# Copyright (C) 2014 GRAP (http://www.grap.coop) |
289 | +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) |
290 | +# |
291 | +# This program is free software: you can redistribute it and/or modify |
292 | +# it under the terms of the GNU Affero General Public License as |
293 | +# published by the Free Software Foundation, either version 3 of the |
294 | +# License, or (at your option) any later version. |
295 | +# |
296 | +# This program is distributed in the hope that it will be useful, |
297 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
298 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
299 | +# GNU Affero General Public License for more details. |
300 | +# |
301 | +# You should have received a copy of the GNU Affero General Public License |
302 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
303 | +# |
304 | +############################################################################## |
305 | + |
306 | +from openerp.tests.common import TransactionCase |
307 | + |
308 | + |
309 | +class TestmoduleParentDependencies(TransactionCase): |
310 | + """Tests for 'DataBase Integrity' Module""" |
311 | + |
312 | + def setUp(self): |
313 | + super(TestmoduleParentDependencies, self).setUp() |
314 | + self.im_obj = self.registry('ir.module.module') |
315 | + |
316 | + # Test Section |
317 | + def test_01_direct_parent(self): |
318 | + """Test if the compute of the field direct_parent_ids is correct.""" |
319 | + cr, uid = self.cr, self.uid |
320 | + # compute expected values |
321 | + cr.execute("""SELECT module_id |
322 | + FROM ir_module_module_dependency immd |
323 | + INNER JOIN ir_module_module imm on imm.id = immd.module_id |
324 | + WHERE immd.name='base' |
325 | + AND imm.state not in ('uninstalled', 'uninstallable')""") |
326 | + expected_parent_ids = [x[0] for x in cr.fetchall()] |
327 | + |
328 | + # Get values |
329 | + base_id = self.im_obj.search(cr, uid, [('name', '=', 'base')]) |
330 | + tmp = self.im_obj.browse( |
331 | + cr, uid, base_id) |
332 | + parent_ids = [x.id for x in tmp[0].direct_parent_ids] |
333 | + |
334 | + self.assertEqual( |
335 | + sorted(parent_ids), sorted(expected_parent_ids), |
336 | + "Incorrect computation of 'direct_parent_id's fields.") |
337 | + |
338 | + def test_02_all_parent(self): |
339 | + """Test if the compute of the field direct_parent_ids doesn't crash.""" |
340 | + cr, uid = self.cr, self.uid |
341 | + base_id = self.im_obj.search(cr, uid, [('name', '=', 'base')]) |
342 | + tmp = self.im_obj.browse( |
343 | + cr, uid, base_id) |
344 | + parent_ids = [x.id for x in tmp[0].all_parent_ids] |
345 | + |
346 | + self.assertNotEqual( |
347 | + sorted(parent_ids), [], |
348 | + "Incorrect computation of 'direct_parent_id's fields.") |
349 | |
350 | === added directory 'module_parent_dependencies/view' |
351 | === added file 'module_parent_dependencies/view/view.xml' |
352 | --- module_parent_dependencies/view/view.xml 1970-01-01 00:00:00 +0000 |
353 | +++ module_parent_dependencies/view/view.xml 2014-07-09 16:10:31 +0000 |
354 | @@ -0,0 +1,40 @@ |
355 | +<?xml version="1.0" encoding="UTF-8"?> |
356 | +<!-- ********************************************************************** --> |
357 | +<!-- odule - Parent Dependencies module for Odoo --> |
358 | +<!-- Copyright (C) 2014- Today GRAP (http://www.grap.coop) --> |
359 | +<!-- @author Sylvain LE GAL (https://twitter.com/legalsylvain) --> |
360 | + |
361 | +<!--This program is free software: you can redistribute it and/or modify --> |
362 | +<!--it under the terms of the GNU Affero General Public License as --> |
363 | +<!--published by the Free Software Foundation, either version 3 of the --> |
364 | +<!--License, or (at your option) any later version. --> |
365 | + |
366 | +<!--This program is distributed in the hope that it will be useful, --> |
367 | +<!--but WITHOUT ANY WARRANTY; without even the implied warranty of --> |
368 | +<!--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> |
369 | +<!--GNU Affero General Public License for more details. --> |
370 | + |
371 | +<!--You should have received a copy of the GNU Affero General Public License--> |
372 | +<!--along with this program. If not, see <http://www.gnu.org/licenses/>. --> |
373 | +<!-- ********************************************************************** --> |
374 | +<openerp> |
375 | + <data> |
376 | + |
377 | + <record id="view_ir_module_module_form" model="ir.ui.view"> |
378 | + <field name="name">ir.module.module.form</field> |
379 | + <field name="model">ir.module.module</field> |
380 | + <field name="inherit_id" ref="base.module_form" /> |
381 | + <field name="arch" type="xml"> |
382 | + <notebook position="inside"> |
383 | + <page string="Parent informations"> |
384 | + <separator string="Direct Parent Modules" colspan="2"/> |
385 | + <field name="direct_parent_ids" /> |
386 | + <separator string="Direct and Indirect Parent Modules" colspan="2"/> |
387 | + <field name="all_parent_ids" /> |
388 | + </page> |
389 | + </notebook> |
390 | + </field> |
391 | + </record> |
392 | + |
393 | + </data> |
394 | +</openerp> |
Sorry, /docs.google. com/spreadsheet s/d/tamE9XSJzre FklZ8ocImXmw/ htmlview? pli=1#gid= 0) /github. com/OCA/ server- tools/pull/ 8
This repository is now readonly. (More information here: https:/
plz rewiew the Pull request on github.
https:/