summaryrefslogtreecommitdiff
path: root/bin/addons/base/module
diff options
context:
space:
mode:
authorVir (Open ERP) <vir@tinyerp.com>2010-06-01 11:08:40 +0530
committerVir (Open ERP) <vir@tinyerp.com>2010-06-01 11:08:40 +0530
commitb2a6a5f79c0ae1cc13f207ca0135d1eb401f2c35 (patch)
tree7aeea0e54926957c1b3181a92f3681626ccd1939 /bin/addons/base/module
parent9a7c0bfa75a8138b442160e96074bd7652f42c10 (diff)
parent2a1d7c24c0e06c5fc383cce4778ca525ecfa5eef (diff)
[Merge] Merge with Trunk Server
bzr revid: vir@tinyerp.com-20100601053840-z183q5is7js83sb9
Diffstat (limited to 'bin/addons/base/module')
-rw-r--r--bin/addons/base/module/module.py91
-rw-r--r--bin/addons/base/module/module_view.xml4
-rw-r--r--bin/addons/base/module/wizard/add_new.py11
3 files changed, 64 insertions, 42 deletions
diff --git a/bin/addons/base/module/module.py b/bin/addons/base/module/module.py
index 1f5f2393c19..e29e95bf68f 100644
--- a/bin/addons/base/module/module.py
+++ b/bin/addons/base/module/module.py
@@ -3,6 +3,7 @@
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -23,6 +24,7 @@ import tarfile
import re
import urllib
import os
+import imp
import tools
from osv import fields, osv, orm
import zipfile
@@ -122,6 +124,8 @@ class module(osv.osv):
'shortdesc': fields.char('Short Description', size=256, readonly=True, translate=True),
'description': fields.text("Description", readonly=True, translate=True),
'author': fields.char("Author", size=128, readonly=True),
+ 'maintainer': fields.char('Maintainer', size=128, readonly=True),
+ 'contributors': fields.text('Contributors', readonly=True),
'website': fields.char("Website", size=256, readonly=True),
# attention: Incorrect field names !!
@@ -191,6 +195,27 @@ class module(osv.osv):
return super(module, self).unlink(cr, uid, ids, context=context)
+ @staticmethod
+ def _check_external_dependencies(terp):
+ depends = terp.get('external_dependencies')
+ if not depends:
+ return
+ for pydep in depends.get('python', []):
+ parts = pydep.split('.')
+ parts.reverse()
+ path = None
+ while parts:
+ part = parts.pop()
+ try:
+ f, path, descr = imp.find_module(part, path and [path] or None)
+ except ImportError:
+ raise ImportError('No module named %s' % (pydep,))
+
+ for binary in depends.get('bin', []):
+ if tools.find_in_path(binary) is None:
+ raise Exception('Unable to find %r in path' % (binary,))
+
+
def state_update(self, cr, uid, ids, newstate, states_to_update, context={}, level=100):
if level<1:
raise orm.except_orm(_('Error'), _('Recursion error in modules dependencies !'))
@@ -206,6 +231,11 @@ class module(osv.osv):
else:
od = self.browse(cr, uid, ids2)[0]
mdemo = od.demo or mdemo
+ terp = self.get_module_info(module.name)
+ try:
+ self._check_external_dependencies(terp)
+ except Exception, e:
+ raise orm.except_orm(_('Error'), _('Unable %s the module "%s" because an external dependencie is not met: %s' % (newstate, module.name, e.args[0])))
if not module.dependencies_id:
mdemo = module.demo
if module.state in states_to_update:
@@ -279,6 +309,19 @@ class module(osv.osv):
self.update_translations(cr, uid, ids)
return True
+ @staticmethod
+ def get_values_from_terp(terp):
+ return {
+ 'description': terp.get('description', ''),
+ 'shortdesc': terp.get('name', ''),
+ 'author': terp.get('author', 'Unknown'),
+ 'maintainer': terp.get('maintainer', False),
+ 'contributors': ', '.join(terp.get('contributors', [])) or False,
+ 'website': terp.get('website', ''),
+ 'license': terp.get('license', 'GPL-2'),
+ 'certificate': terp.get('certificate') or None,
+ }
+
# update the list of available packages
def update_list(self, cr, uid, context={}):
res = [0, 0] # [update, add]
@@ -286,46 +329,31 @@ class module(osv.osv):
# iterate through installed modules and mark them as being so
for mod_name in addons.get_modules():
ids = self.search(cr, uid, [('name','=',mod_name)])
+
+ terp = self.get_module_info(mod_name)
+ values = self.get_values_from_terp(terp)
+
if ids:
id = ids[0]
mod = self.browse(cr, uid, id)
- terp = self.get_module_info(mod_name)
if terp.get('installable', True) and mod.state == 'uninstallable':
self.write(cr, uid, id, {'state': 'uninstalled'})
if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''):
self.write(cr, uid, id, { 'url': ''})
res[0] += 1
- self.write(cr, uid, id, {
- 'description': terp.get('description', ''),
- 'shortdesc': terp.get('name', ''),
- 'author': terp.get('author', 'Unknown'),
- 'website': terp.get('website', ''),
- 'license': terp.get('license', 'GPL-2'),
- 'certificate': terp.get('certificate') or None,
- })
+ self.write(cr, uid, id, values)
cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s', (id,))
- self._update_dependencies(cr, uid, ids[0], terp.get('depends', []))
- self._update_category(cr, uid, ids[0], terp.get('category', 'Uncategorized'))
- continue
- mod_path = addons.get_module_path(mod_name)
- if mod_path:
- terp = self.get_module_info(mod_name)
+ else:
+ mod_path = addons.get_module_path(mod_name)
+ if not mod_path:
+ continue
if not terp or not terp.get('installable', True):
continue
- id = self.create(cr, uid, {
- 'name': mod_name,
- 'state': 'uninstalled',
- 'description': terp.get('description', ''),
- 'shortdesc': terp.get('name', ''),
- 'author': terp.get('author', 'Unknown'),
- 'website': terp.get('website', ''),
- 'license': terp.get('license', 'GPL-2'),
- 'certificate': terp.get('certificate') or None,
- })
+ id = self.create(cr, uid, dict(name=mod_name, state='uninstalled', **values))
res[1] += 1
- self._update_dependencies(cr, uid, id, terp.get('depends', []))
- self._update_category(cr, uid, id, terp.get('category', 'Uncategorized'))
+ self._update_dependencies(cr, uid, id, terp.get('depends', []))
+ self._update_category(cr, uid, id, terp.get('category', 'Uncategorized'))
return res
@@ -352,14 +380,7 @@ class module(osv.osv):
except Exception, e:
raise orm.except_orm(_('Error'), _('Can not create the module file:\n %s') % (fname,))
terp = self.get_module_info(mod.name)
- self.write(cr, uid, mod.id, {
- 'description': terp.get('description', ''),
- 'shortdesc': terp.get('name', ''),
- 'author': terp.get('author', 'Unknown'),
- 'website': terp.get('website', ''),
- 'license': terp.get('license', 'GPL-2'),
- 'certificate': terp.get('certificate') or None,
- })
+ self.write(cr, uid, mod.id, self.get_values_from_terp(terp))
cr.execute('DELETE FROM ir_module_module_dependency ' \
'WHERE module_id = %s', (mod.id,))
self._update_dependencies(cr, uid, mod.id, terp.get('depends',
diff --git a/bin/addons/base/module/module_view.xml b/bin/addons/base/module/module_view.xml
index cd57b59023c..63484b97d43 100644
--- a/bin/addons/base/module/module_view.xml
+++ b/bin/addons/base/module/module_view.xml
@@ -97,7 +97,9 @@
<field name="latest_version"/>
<field name="author" select="2"/>
<field name="website" select="2" widget="url"/>
+ <field name="maintainer" attrs="{'invisible': [('maintainer', '=', False)]}"/>
<field name="url" widget="url"/>
+ <field name="contributors" widget="char" attrs="{'invisible': [('contributors', '=', False)]}"/>
<field name="published_version"/>
<field name="license"/>
<field name="demo" readonly="1"/>
@@ -141,6 +143,8 @@
<field name="name"/>
<field name="shortdesc"/>
<field name="author"/>
+ <field name='maintainer'/>
+ <field name='contributors'/>
<field name="installed_version"/>
<field name="latest_version"/>
<field name="published_version"/>
diff --git a/bin/addons/base/module/wizard/add_new.py b/bin/addons/base/module/wizard/add_new.py
index 0e2028e7624..c6eddab2adb 100644
--- a/bin/addons/base/module/wizard/add_new.py
+++ b/bin/addons/base/module/wizard/add_new.py
@@ -3,6 +3,7 @@
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+# Copyright (C) 2010 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -56,7 +57,7 @@ class wizard_install_module(wizard.interface):
terp = mod_obj.get_module_info(module)
if not terp.get('installable', True):
continue
-
+
# XXX check if this code is correct...
fm = imp.find_module(module)
try:
@@ -65,12 +66,8 @@ class wizard_install_module(wizard.interface):
if fm[0]:
fm[0].close()
- mod_id = mod_obj.create(cr, uid, {
- 'name': module,
- 'state': 'uninstalled',
- 'description': terp.get('description', ''),
- 'shortdesc': terp.get('name', ''),
- 'author': terp.get('author', 'Unknown')})
+ values = mod_obj.get_values_from_terp(terp)
+ mod_id = mod_obj.create(cr, uid, dict(name=module, state='uninstalled', **values))
dependencies = terp.get('depends', [])
for d in dependencies:
cr.execute('insert into ir_module_module_dependency (module_id,name) values (%s, %s)', (mod_id, d))