Vo Minh Thu (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-auto-install-vmt into
lp:openobject-server.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-auto-install-vmt/+merge/90715
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-auto-install-vmt/+merge/90715
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-auto-install-vmt.
=== modified file 'openerp/addons/base/__openerp__.py'
--- openerp/addons/base/__openerp__.py 2012-01-07 04:17:45 +0000
+++ openerp/addons/base/__openerp__.py 2012-01-30 15:34:10 +0000
@@ -97,7 +97,7 @@
# 'test/test_ir_cron.yml', # <-- These tests perform a roolback.
],
'installable': True,
- 'active': True,
+ 'auto_install': True,
'certificate': '0076807797149',
"css": [ 'static/src/css/modules.css' ],
}
=== modified file 'openerp/addons/base/base.sql'
--- openerp/addons/base/base.sql 2012-01-07 04:17:45 +0000
+++ openerp/addons/base/base.sql 2012-01-30 15:34:10 +0000
@@ -302,6 +302,7 @@
web boolean DEFAULT FALSE,
license character varying(32),
sequence integer DEFAULT 100,
+ auto_install boolean default False,
primary key(id)
);
ALTER TABLE ir_module_module add constraint name_uniq unique (name);
=== modified file 'openerp/addons/base/module/module.py'
--- openerp/addons/base/module/module.py 2012-01-07 04:17:45 +0000
+++ openerp/addons/base/module/module.py 2012-01-30 15:34:10 +0000
@@ -192,6 +192,10 @@
'sequence': fields.integer('Sequence'),
'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.'),
'state': fields.selection([
('uninstallable','Not Installable'),
('uninstalled','Not Installed'),
@@ -318,20 +322,27 @@
return demo
def button_install(self, cr, uid, ids, context=None):
- model_obj = self.pool.get('ir.model.data')
+
+ # Mark the given modules to be installed.
self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context)
- categ = model_obj.get_object(cr, uid, 'base', 'module_category_hidden_links', context=context)
- todo = []
- for mod in categ.module_ids:
- if mod.state=='uninstalled':
- ok = True
- for dep in mod.dependencies_id:
- ok = ok and (dep.state in ('to install','installed'))
- if ok:
- todo.append(mod.id)
- if todo:
- self.button_install(cr, uid, todo, context=context)
+ # 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),]
+ uninstalled_ids = self.search(cr, uid, domain, context=context)
+ uninstalled_modules = self.browse(cr, uid, uninstalled_ids, context=context)
+
+ # Keep those with all their dependencies satisfied.
+ def all_depencies_satisfied(m):
+ return all(x.state in ('to install', 'installed', 'to upgrade') for x in m.dependencies_id)
+ to_install_modules = filter(all_depencies_satisfied, uninstalled_modules)
+ to_install_ids = map(lambda m: m.id, to_install_modules)
+
+ # Mark them to be installed.
+ if to_install_ids:
+ self.button_install(cr, uid, to_install_ids, context=context)
+
return dict(ACTION_DICT, name=_('Install'))
def button_immediate_install(self, cr, uid, ids, context=None):
@@ -439,6 +450,7 @@
'complexity': terp.get('complexity', ''),
'sequence': terp.get('sequence', 100),
'application': terp.get('application', False),
+ 'auto_install': terp.get('auto_install', False),
}
# update the list of available packages
=== modified file 'openerp/addons/base/module/module_data.xml'
--- openerp/addons/base/module/module_data.xml 2011-12-20 08:37:16 +0000
+++ openerp/addons/base/module/module_data.xml 2012-01-30 15:34:10 +0000
@@ -7,13 +7,6 @@
<field name="visible" eval="0" />
</record>
- <record model="ir.module.category" id="module_category_hidden_links">
- <field name="parent_id" ref="module_category_hidden" />
- <field name="name">Links</field>
- <field name="sequence">0</field>
- <field name="visible" eval="0" />
- </record>
-
<record model="ir.module.category" id="module_category_localization">
<field name="name">Localization</field>
<field name="visible" eval="0" />
=== modified file 'openerp/modules/db.py'
--- openerp/modules/db.py 2012-01-07 04:17:45 +0000
+++ openerp/modules/db.py 2012-01-30 15:34:10 +0000
@@ -66,7 +66,7 @@
category_id = create_categories(cr, categories)
if info['installable']:
- if info['active']:
+ if info['auto_install'] and not info['depends']:
state = 'to install'
else:
state = 'uninstalled'
@@ -75,11 +75,12 @@
cr.execute('INSERT INTO ir_module_module \
(author, website, name, shortdesc, description, \
- category_id, state, certificate, web, license, complexity, application, icon, sequence) \
- VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id', (
+ category_id, auto_install, state, certificate, web, license, complexity, application, icon, sequence) \
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id', (
info['author'],
info['website'], i, info['name'],
- info['description'], category_id, state, info['certificate'],
+ info['description'], category_id,
+ info['auto_install'], state, info['certificate'],
info['web'],
info['license'],
info['complexity'], info['application'], info['icon'],
=== modified file 'openerp/modules/module.py'
--- openerp/modules/module.py 2012-01-10 09:27:30 +0000
+++ openerp/modules/module.py 2012-01-30 15:34:10 +0000
@@ -48,6 +48,8 @@
import openerp.modules.db
import openerp.modules.graph
+_logger = logging.getLogger(__name__)
+
_ad = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'addons') # default addons path (base)
ad_paths = []
@@ -317,7 +319,6 @@
if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'):
# default values for descriptor
info = {
- 'active': False,
'application': False,
'author': '',
'category': 'Uncategorized',
@@ -327,6 +328,7 @@
'description': '',
'icon': get_module_icon(module),
'installable': True,
+ 'auto_install': False,
'license': 'AGPL-3',
'name': False,
'post_load': None,
@@ -342,6 +344,12 @@
with tools.file_open(terp_file) as terp_f:
info.update(eval(terp_f.read()))
+ if 'active' in info:
+ _logger.warning('The module `%s` uses the deprecated entry '
+ '`active` in its manifest file. It should use the entry '
+ '`auto_install`.', module)
+ info['auto_install'] = info['active']
+
return info
#TODO: refactor the logger in this file to follow the logging guidelines
=== modified file 'openerp/tests/addons/test_exceptions/__openerp__.py'
--- openerp/tests/addons/test_exceptions/__openerp__.py 2011-09-30 09:37:55 +0000
+++ openerp/tests/addons/test_exceptions/__openerp__.py 2012-01-30 15:34:10 +0000
@@ -10,6 +10,6 @@
'depends': ['base'],
'data': ['view.xml'],
'installable': True,
- 'active': False,
+ 'auto_install': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'openerp/tests/addons/test_limits/__openerp__.py'
--- openerp/tests/addons/test_limits/__openerp__.py 2012-01-20 11:46:12 +0000
+++ openerp/tests/addons/test_limits/__openerp__.py 2012-01-30 15:34:10 +0000
@@ -10,6 +10,6 @@
'depends': ['base'],
'data': [],
'installable': True,
- 'active': False,
+ 'auto_install': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp