summaryrefslogtreecommitdiff
path: root/bin/addons/base/module/module.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/addons/base/module/module.py')
-rw-r--r--bin/addons/base/module/module.py114
1 files changed, 80 insertions, 34 deletions
diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py
index 836a6a3ed7d..579231724b2 100644
--- a/bin/addons/base/module/module.py
+++ b/bin/addons/base/module/module.py
@@ -1,30 +1,22 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+# $Id$
#
-# $Id$
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
#
-# WARNING: This program as such is intended to be used by professional
-# programmers who take the whole responsability of assessing all potential
-# consequences resulting from its eventual inadequacies and bugs
-# End users who are looking for a ready-to-use solution with commercial
-# garantees and support are strongly adviced to contract a Free Software
-# Service Company
+# 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 General Public License for more details.
#
-# This program is Free Software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -219,6 +211,51 @@ class module(osv.osv):
res[m.id] = ''
return res
+ def _get_menus(self, cr, uid, ids, field_name=None, arg=None, context={}):
+ res = {}
+ model_data_obj = self.pool.get('ir.model.data')
+ menu_obj = self.pool.get('ir.ui.menu')
+ for m in self.browse(cr, uid, ids):
+ if m.state == 'installed':
+ menu_txt = ''
+ menus_id = model_data_obj.search(cr,uid,[('module','=',m.name),('model','=','ir.ui.menu')])
+ for data_id in model_data_obj.browse(cr,uid,menus_id):
+ menu_txt += menu_obj.browse(cr,uid,data_id.res_id).complete_name + '\n'
+ res[m.id] = menu_txt
+ else:
+ res[m.id] = ''
+ return res
+
+ def _get_reports(self, cr, uid, ids, field_name=None, arg=None, context={}):
+ res = {}
+ model_data_obj = self.pool.get('ir.model.data')
+ report_obj = self.pool.get('ir.actions.report.xml')
+ for m in self.browse(cr, uid, ids):
+ if m.state == 'installed':
+ report_txt = ''
+ report_id = model_data_obj.search(cr,uid,[('module','=',m.name),('model','=','ir.actions.report.xml')])
+ for data_id in model_data_obj.browse(cr,uid,report_id):
+ report_txt += report_obj.browse(cr,uid,data_id.res_id).name + '\n'
+ res[m.id] = report_txt
+ else:
+ res[m.id] = ''
+ return res
+
+ def _get_views(self, cr, uid, ids, field_name=None, arg=None, context={}):
+ res = {}
+ model_data_obj = self.pool.get('ir.model.data')
+ view_obj = self.pool.get('ir.ui.view')
+ for m in self.browse(cr, uid, ids, context=context):
+ if m.state == 'installed':
+ view_txt = ''
+ view_id = model_data_obj.search(cr,uid,[('module','=',m.name),('model','=','ir.ui.view')])
+ for data_id in model_data_obj.browse(cr,uid,view_id):
+ view_txt += view_obj.browse(cr,uid,data_id.res_id).name + '\n'
+ res[m.id] = view_txt
+ else:
+ res[m.id] = ''
+ return res
+
_columns = {
'name': fields.char("Name", size=128, readonly=True, required=True),
'category_id': fields.many2one('ir.module.category', 'Category', readonly=True),
@@ -242,9 +279,16 @@ class module(osv.osv):
('to install','To be installed')
], string='State', readonly=True),
'demo': fields.boolean('Demo data'),
- 'license': fields.selection([('GPL-2', 'GPL-2'),('GPL-3', 'GPL-3'),
- ('Other proprietary', 'Other proprietary')], string='License',
- readonly=True),
+ 'license': fields.selection([
+ ('GPL-2', 'GPL-2'),
+ ('GPL-2 or any later version', 'GPL-2 or later version'),
+ ('GPL-3', 'GPL-3'),
+ ('GPL-3 or any later version', 'GPL-3 or later version'),
+ ('Other proprietary', 'Other proprietary')
+ ], string='License', readonly=True),
+ 'menus_by_module': fields.function(_get_menus, method=True, string='Menus', type='text'),
+ 'reports_by_module': fields.function(_get_reports, method=True, string='Reports', type='text'),
+ 'views_by_module': fields.function(_get_views, method=True, string='Views', type='text'),
}
_defaults = {
@@ -310,7 +354,7 @@ class module(osv.osv):
m.state not in ('uninstalled','uninstallable','to remove')''', (module.name,))
res = cr.fetchall()
if res:
- raise orm.except_orm(_('Error'), _('The module you are trying to remove depends on installed modules :\n %s') % '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res)))
+ raise orm.except_orm(_('Error'), _('Some installed modules depends on the module you plan to desinstall :\n %s') % '\n'.join(map(lambda x: '\t%s: %s' % (x[0], x[1]), res)))
self.write(cr, uid, ids, {'state': 'to remove'})
return True
@@ -380,7 +424,7 @@ class module(osv.osv):
continue
terp_file = addons.get_module_resource(name, '__terp__.py')
mod_path = addons.get_module_path(name)
- if os.path.isdir(mod_path) or os.path.islink(mod_path) or zipfile.is_zipfile(mod_path):
+ if mod_path and (os.path.isdir(mod_path) or os.path.islink(mod_path) or zipfile.is_zipfile(mod_path)):
terp = self.get_module_info(mod_name)
if not terp or not terp.get('installable', True):
continue
@@ -528,10 +572,12 @@ class module(osv.osv):
self.write(cr, uid, [id], {'category_id': p_id})
def action_install(self,cr,uid,ids,context=None):
- self.write(cr , uid, ids ,{'state' : 'to install'})
- self.download(cr, uid, ids, context=context)
- for id in ids:
- cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%d and m.state='uninstalled'",(id,))
+ for module in self.browse(cr, uid, ids, context):
+ if module.state <> 'uninstalled':
+ continue
+ self.write(cr , uid, [module.id] ,{'state' : 'to install'})
+ self.download(cr, uid, [module.id], context=context)
+ cr.execute("select m.id as id from ir_module_module_dependency d inner join ir_module_module m on (m.name=d.name) where d.module_id=%d and m.state='uninstalled'",(module.id,))
dep_ids = map(lambda x:x[0],cr.fetchall())
if len(dep_ids):
self.action_install(cr,uid,dep_ids,context=context)
@@ -541,9 +587,9 @@ class module(osv.osv):
if not filter_lang:
pool = pooler.get_pool(cr.dbname)
- lang_obj=pool.get('res.lang')
- lang_ids=lang_obj.search(cr, uid, [('translatable', '=', True)])
- filter_lang= [lang.code for lang in lang_obj.browse(cr, uid, lang_ids)]
+ lang_obj = pool.get('res.lang')
+ lang_ids = lang_obj.search(cr, uid, [('translatable', '=', True)])
+ filter_lang = [lang.code for lang in lang_obj.browse(cr, uid, lang_ids)]
elif not isinstance(filter_lang, (list, tuple)):
filter_lang = [filter_lang]
@@ -554,7 +600,7 @@ class module(osv.osv):
for lang in filter_lang:
f = os.path.join(tools.config['addons_path'], mod.name, 'i18n', lang + '.po')
if os.path.exists(f):
- logger.notifyChannel("init", netsvc.LOG_INFO, 'addons %s: loading translation file for language %s' % (mod.name, lang))
+ logger.notifyChannel("init", netsvc.LOG_INFO, 'addon %s: loading translation file for language %s' % (mod.name, lang))
tools.trans_load(cr.dbname, f, lang, verbose=False)
module()