diff --git a/openerp/addons/base/module/module.py b/openerp/addons/base/module/module.py
index fc13d3affc3..455d68c5371 100644
--- a/openerp/addons/base/module/module.py
+++ b/openerp/addons/base/module/module.py
@@ -18,8 +18,6 @@
# along with this program. If not, see .
#
##############################################################################
-from collections import defaultdict
-import base64
from docutils.core import publish_string
import imp
import logging
@@ -38,7 +36,7 @@ except ImportError:
from StringIO import StringIO # NOQA
import openerp
-from openerp import modules, pooler, release, tools, addons
+from openerp import modules, pooler, tools, addons
from openerp.tools.parse_version import parse_version
from openerp.tools.translate import _
from openerp.osv import fields, osv, orm
@@ -51,7 +49,7 @@ ACTION_DICT = {
'res_model': 'base.module.upgrade',
'target': 'new',
'type': 'ir.actions.act_window',
- 'nodestroy':True,
+ 'nodestroy': True,
}
def backup(path, raise_exception=True):
@@ -73,7 +71,7 @@ class module_category(osv.osv):
_name = "ir.module.category"
_description = "Application"
- def _module_nbr(self,cr,uid, ids, prop, unknow_none, context):
+ def _module_nbr(self, cr, uid, ids, prop, unknow_none, context):
cr.execute('SELECT category_id, COUNT(*) \
FROM ir_module_module \
WHERE category_id IN %(ids)s \
@@ -81,7 +79,7 @@ class module_category(osv.osv):
FROM ir_module_category \
WHERE parent_id IN %(ids)s) \
GROUP BY category_id', {'ids': tuple(ids)}
- )
+ )
result = dict(cr.fetchall())
for id in ids:
cr.execute('select id from ir_module_category where parent_id=%s', (id,))
@@ -94,16 +92,16 @@ class module_category(osv.osv):
'parent_id': fields.many2one('ir.module.category', 'Parent Application', select=True),
'child_ids': fields.one2many('ir.module.category', 'parent_id', 'Child Applications'),
'module_nr': fields.function(_module_nbr, string='Number of Modules', type='integer'),
- 'module_ids' : fields.one2many('ir.module.module', 'category_id', 'Modules'),
- 'description' : fields.text("Description", translate=True),
- 'sequence' : fields.integer('Sequence'),
- 'visible' : fields.boolean('Visible'),
+ 'module_ids': fields.one2many('ir.module.module', 'category_id', 'Modules'),
+ 'description': fields.text("Description", translate=True),
+ 'sequence': fields.integer('Sequence'),
+ 'visible': fields.boolean('Visible'),
'xml_id': fields.function(osv.osv.get_external_id, type='char', size=128, string="External ID"),
}
_order = 'name'
_defaults = {
- 'visible' : 1,
+ 'visible': 1,
}
class module(osv.osv):
@@ -164,9 +162,11 @@ class module(osv.osv):
continue
# then, search and group ir.model.data records
- imd_models = dict( [(m,[]) for m in dmodels])
- imd_ids = model_data_obj.search(cr,uid,[('module','=', module_rec.name),
- ('model','in',tuple(dmodels))])
+ imd_models = dict([(m, []) for m in dmodels])
+ imd_ids = model_data_obj.search(cr, uid, [
+ ('module', '=', module_rec.name),
+ ('model', 'in', tuple(dmodels))
+ ])
for imd_res in model_data_obj.read(cr, uid, imd_ids, ['model', 'res_id'], context=context):
imd_models[imd_res['model']].append(imd_res['res_id'])
@@ -178,7 +178,7 @@ class module(osv.osv):
view_ids = imd_models.get('ir.ui.view', [])
for v in view_obj.browse(cr, uid, view_ids, context=context):
aa = v.inherit_id and '* INHERIT ' or ''
- res_mod_dic['views_by_module'].append(aa + v.name + '('+v.type+')')
+ res_mod_dic['views_by_module'].append('%s%s (%s)' % (aa, v.name, v.type))
report_ids = imd_models.get('ir.actions.report.xml', [])
for rx in report_obj.browse(cr, uid, report_ids, context=context):
@@ -188,15 +188,13 @@ class module(osv.osv):
for um in menu_obj.browse(cr, uid, menu_ids, context=context):
res_mod_dic['menus_by_module'].append(um.complete_name)
except KeyError, e:
- _logger.warning(
- 'Data not found for items of %s', module_rec.name)
+ _logger.warning('Data not found for items of %s', module_rec.name)
except AttributeError, e:
- _logger.warning(
- 'Data not found for items of %s %s', module_rec.name, str(e))
+ _logger.warning('Data not found for items of %s %s', module_rec.name, str(e))
except Exception, e:
- _logger.warning('Unknown error while fetching data of %s',
- module_rec.name, exc_info=True)
- for key, _ in res.iteritems():
+ _logger.warning('Unknown error while fetching data of %s', module_rec.name, exc_info=True)
+
+ for key in res.iterkeys():
for k, v in res[key].iteritems():
res[key][k] = "\n".join(sorted(v))
return res
@@ -229,41 +227,39 @@ class module(osv.osv):
# installed_version refer the latest version (the one on disk)
# latest_version refer the installed version (the one in database)
# published_version refer the version available on the repository
- 'installed_version': fields.function(_get_latest_version,
- string='Latest Version', type='char'),
+ 'installed_version': fields.function(_get_latest_version, string='Latest Version', type='char'),
'latest_version': fields.char('Installed Version', size=64, readonly=True),
'published_version': fields.char('Published Version', size=64, readonly=True),
'url': fields.char('URL', size=128, readonly=True),
'sequence': fields.integer('Sequence'),
- 'dependencies_id': fields.one2many('ir.module.module.dependency',
- 'module_id', 'Dependencies', readonly=True),
+ 'dependencies_id': fields.one2many('ir.module.module.dependency', 'module_id', 'Dependencies', readonly=True),
'auto_install': fields.boolean('Automatic Installation',
- help='An auto-installable module is automatically installed by the '
- 'system when all its dependencies are satisfied. '
- 'If the module has no dependency, it is always installed.'),
+ help='An auto-installable module is automatically installed by the '
+ 'system when all its dependencies are satisfied. '
+ 'If the module has no dependency, it is always installed.'),
'state': fields.selection([
- ('uninstallable','Not Installable'),
- ('uninstalled','Not Installed'),
- ('installed','Installed'),
- ('to upgrade','To be upgraded'),
- ('to remove','To be removed'),
- ('to install','To be installed')
+ ('uninstallable', 'Not Installable'),
+ ('uninstalled', 'Not Installed'),
+ ('installed', 'Installed'),
+ ('to upgrade', 'To be upgraded'),
+ ('to remove', 'To be removed'),
+ ('to install', 'To be installed')
], string='State', readonly=True, select=True),
'demo': fields.boolean('Demo Data', readonly=True),
'license': fields.selection([
- ('GPL-2', 'GPL Version 2'),
- ('GPL-2 or any later version', 'GPL-2 or later version'),
- ('GPL-3', 'GPL Version 3'),
- ('GPL-3 or any later version', 'GPL-3 or later version'),
- ('AGPL-3', 'Affero GPL-3'),
- ('Other OSI approved licence', 'Other OSI Approved Licence'),
- ('Other proprietary', 'Other Proprietary')
+ ('GPL-2', 'GPL Version 2'),
+ ('GPL-2 or any later version', 'GPL-2 or later version'),
+ ('GPL-3', 'GPL Version 3'),
+ ('GPL-3 or any later version', 'GPL-3 or later version'),
+ ('AGPL-3', 'Affero GPL-3'),
+ ('Other OSI approved licence', 'Other OSI Approved Licence'),
+ ('Other proprietary', 'Other Proprietary')
], string='License', readonly=True),
'menus_by_module': fields.function(_get_views, string='Menus', type='text', multi="meta", store=True),
'reports_by_module': fields.function(_get_views, string='Reports', type='text', multi="meta", store=True),
'views_by_module': fields.function(_get_views, string='Views', type='text', multi="meta", store=True),
- 'certificate' : fields.char('Quality Certificate', size=64, readonly=True),
+ 'certificate': fields.char('Quality Certificate', size=64, readonly=True),
'application': fields.boolean('Application', readonly=True),
'icon': fields.char('Icon URL', size=128),
'icon_image': fields.function(_get_icon_image, string='Icon', type="binary"),
@@ -283,8 +279,8 @@ class module(osv.osv):
return _('The certificate ID of the module must be unique !')
_sql_constraints = [
- ('name_uniq', 'UNIQUE (name)',_name_uniq_msg ),
- ('certificate_uniq', 'UNIQUE (certificate)',_certificate_uniq_msg )
+ ('name_uniq', 'UNIQUE (name)', _name_uniq_msg),
+ ('certificate_uniq', 'UNIQUE (certificate)', _certificate_uniq_msg)
]
def unlink(self, cr, uid, ids, context=None):
@@ -293,10 +289,9 @@ class module(osv.osv):
if isinstance(ids, (int, long)):
ids = [ids]
mod_names = []
- for mod in self.read(cr, uid, ids, ['state','name'], context):
+ for mod in self.read(cr, uid, ids, ['state', 'name'], context):
if mod['state'] in ('installed', 'to upgrade', 'to remove', 'to install'):
- raise orm.except_orm(_('Error'),
- _('You try to remove a module that is installed or will be installed'))
+ raise orm.except_orm(_('Error'), _('You try to remove a module that is installed or will be installed'))
mod_names.append(mod['name'])
#Removing the entry from ir_model_data
#ids_meta = self.pool.get('ir.model.data').search(cr, uid, [('name', '=', 'module_meta_information'), ('module', 'in', mod_names)])
@@ -341,7 +336,7 @@ class module(osv.osv):
raise orm.except_orm(_('Error'), msg % (module_name, e.args[0]))
def state_update(self, cr, uid, ids, newstate, states_to_update, context=None, level=100):
- if level<1:
+ if level < 1:
raise orm.except_orm(_('Error'), _('Recursion error in modules dependencies !'))
demo = False
for module in self.browse(cr, uid, ids, context=context):
@@ -349,9 +344,9 @@ class module(osv.osv):
for dep in module.dependencies_id:
if dep.state == 'unknown':
raise orm.except_orm(_('Error'), _("You try to install module '%s' that depends on module '%s'.\nBut the latter module is not available in your system.") % (module.name, dep.name,))
- ids2 = self.search(cr, uid, [('name','=',dep.name)])
+ ids2 = self.search(cr, uid, [('name', '=', dep.name)])
if dep.state != newstate:
- mdemo = self.state_update(cr, uid, ids2, newstate, states_to_update, context, level-1,) or mdemo
+ mdemo = self.state_update(cr, uid, ids2, newstate, states_to_update, context, level - 1) or mdemo
else:
od = self.browse(cr, uid, ids2)[0]
mdemo = od.demo or mdemo
@@ -360,7 +355,7 @@ class module(osv.osv):
if not module.dependencies_id:
mdemo = module.demo
if module.state in states_to_update:
- self.write(cr, uid, [module.id], {'state': newstate, 'demo':mdemo})
+ self.write(cr, uid, [module.id], {'state': newstate, 'demo': mdemo})
demo = demo or mdemo
return demo
@@ -372,7 +367,7 @@ class module(osv.osv):
# Mark (recursively) the newly satisfied modules to also be installed:
# Select all auto-installable (but not yet installed) modules.
- domain = [('state', '=', 'uninstalled'), ('auto_install', '=', True),]
+ domain = [('state', '=', 'uninstalled'), ('auto_install', '=', True)]
uninstalled_ids = self.search(cr, uid, domain, context=context)
uninstalled_modules = self.browse(cr, uid, uninstalled_ids, context=context)
@@ -398,7 +393,7 @@ class module(osv.osv):
return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
def button_install_cancel(self, cr, uid, ids, context=None):
- self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False})
+ self.write(cr, uid, ids, {'state': 'uninstalled', 'demo': False})
return True
def module_uninstall(self, cr, uid, ids, context=None):
@@ -416,12 +411,13 @@ class module(osv.osv):
return True
def downstream_dependencies(self, cr, uid, ids, known_dep_ids=None,
- exclude_states=['uninstalled','uninstallable','to remove'],
+ exclude_states=['uninstalled', 'uninstallable', 'to remove'],
context=None):
"""Return the ids of all modules that directly or indirectly depend
on the given module `ids`, and that satisfy the `exclude_states`
filter"""
- if not ids: return []
+ if not ids:
+ return []
known_dep_ids = set(known_dep_ids or [])
cr.execute('''SELECT DISTINCT m.id
FROM
@@ -432,13 +428,13 @@ class module(osv.osv):
d.name IN (SELECT name from ir_module_module where id in %s) AND
m.state NOT IN %s AND
m.id NOT IN %s ''',
- (tuple(ids),tuple(exclude_states), tuple(known_dep_ids or ids)))
+ (tuple(ids), tuple(exclude_states), tuple(known_dep_ids or ids)))
new_dep_ids = set([m[0] for m in cr.fetchall()])
missing_mod_ids = new_dep_ids - known_dep_ids
known_dep_ids |= new_dep_ids
if missing_mod_ids:
known_dep_ids |= set(self.downstream_dependencies(cr, uid, list(missing_mod_ids),
- known_dep_ids, exclude_states,context))
+ known_dep_ids, exclude_states, context))
return list(known_dep_ids)
def _button_immediate_function(self, cr, uid, ids, function, context=None):
@@ -456,9 +452,9 @@ class module(osv.osv):
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
return {
- 'type' : 'ir.actions.client',
- 'tag' : 'reload',
- 'params' : {'menu_id' : menu_ids and menu_ids[0] or False}
+ 'type': 'ir.actions.client',
+ 'tag': 'reload',
+ 'params': {'menu_id': menu_ids and menu_ids[0] or False}
}
def button_immediate_uninstall(self, cr, uid, ids, context=None):
@@ -492,20 +488,19 @@ class module(osv.osv):
self.update_list(cr, uid)
i = 0
- while i