From 5b63c4f560fb4103feb1d87313c4167be84e2daa Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 26 Jan 2012 17:40:49 +0100 Subject: [PATCH 1/6] [IMP] ir.module.module: change `active` flag to `auto_installable`. An auto-installable module is a module automatically installed by the OpenERP server as soon as its dependencies are satisfied, without explicit user action. bzr revid: vmt@openerp.com-20120126164049-smrcvrojy0b1z6f8 --- openerp/addons/base/__openerp__.py | 2 +- openerp/addons/base/base.sql | 1 + openerp/addons/base/module/module.py | 36 ++++++++++++++++++---------- openerp/modules/db.py | 9 +++---- openerp/modules/module.py | 1 + 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py index ab9231b129c..c1bc50058f7 100644 --- a/openerp/addons/base/__openerp__.py +++ b/openerp/addons/base/__openerp__.py @@ -97,7 +97,7 @@ # 'test/test_ir_cron.yml', # <-- These tests perform a roolback. ], 'installable': True, - 'active': True, + 'auto_installable': True, 'certificate': '0076807797149', "css": [ 'static/src/css/modules.css' ], } diff --git a/openerp/addons/base/base.sql b/openerp/addons/base/base.sql index 31872b46730..2b3bec3308b 100644 --- a/openerp/addons/base/base.sql +++ b/openerp/addons/base/base.sql @@ -302,6 +302,7 @@ CREATE TABLE ir_module_module ( web boolean DEFAULT FALSE, license character varying(32), sequence integer DEFAULT 100, + auto_installable boolean default False, primary key(id) ); ALTER TABLE ir_module_module add constraint name_uniq unique (name); diff --git a/openerp/addons/base/module/module.py b/openerp/addons/base/module/module.py index 34ed48378e6..808a89f6120 100644 --- a/openerp/addons/base/module/module.py +++ b/openerp/addons/base/module/module.py @@ -192,6 +192,10 @@ class module(osv.osv): 'sequence': fields.integer('Sequence'), 'dependencies_id': fields.one2many('ir.module.module.dependency', 'module_id', 'Dependencies', readonly=True), + 'auto_installable': fields.boolean('Auto Installable', + 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 @@ class module(osv.osv): 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_installable', '=', 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 @@ class module(osv.osv): 'complexity': terp.get('complexity', ''), 'sequence': terp.get('sequence', 100), 'application': terp.get('application', False), + 'auto_installable': terp.get('auto_installable', False), } # update the list of available packages diff --git a/openerp/modules/db.py b/openerp/modules/db.py index a670a29deed..df25013ecf3 100644 --- a/openerp/modules/db.py +++ b/openerp/modules/db.py @@ -66,7 +66,7 @@ def initialize(cr): category_id = create_categories(cr, categories) if info['installable']: - if info['active']: + if info['auto_installable'] and not info['depends']: state = 'to install' else: state = 'uninstalled' @@ -75,11 +75,12 @@ def initialize(cr): 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_installable, 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_installable'], state, info['certificate'], info['web'], info['license'], info['complexity'], info['application'], info['icon'], diff --git a/openerp/modules/module.py b/openerp/modules/module.py index b82597d656d..acf883c2158 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -327,6 +327,7 @@ def load_information_from_description_file(module): 'description': '', 'icon': get_module_icon(module), 'installable': True, + 'auto_installable': False, 'license': 'AGPL-3', 'name': False, 'post_load': None, From 0d86e08450ec2794e84e96d5325b3aba62570679 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 30 Jan 2012 10:52:38 +0100 Subject: [PATCH 2/6] [IMP] manifest: `auto_installable` renamed to `auto_install`. bzr revid: vmt@openerp.com-20120130095238-x2by4y11joeytipr --- openerp/addons/base/__openerp__.py | 2 +- openerp/addons/base/base.sql | 2 +- openerp/addons/base/module/module.py | 6 +++--- openerp/modules/db.py | 6 +++--- openerp/modules/module.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/openerp/addons/base/__openerp__.py b/openerp/addons/base/__openerp__.py index c1bc50058f7..592a8b5f426 100644 --- a/openerp/addons/base/__openerp__.py +++ b/openerp/addons/base/__openerp__.py @@ -97,7 +97,7 @@ # 'test/test_ir_cron.yml', # <-- These tests perform a roolback. ], 'installable': True, - 'auto_installable': True, + 'auto_install': True, 'certificate': '0076807797149', "css": [ 'static/src/css/modules.css' ], } diff --git a/openerp/addons/base/base.sql b/openerp/addons/base/base.sql index 2b3bec3308b..409ce81b285 100644 --- a/openerp/addons/base/base.sql +++ b/openerp/addons/base/base.sql @@ -302,7 +302,7 @@ CREATE TABLE ir_module_module ( web boolean DEFAULT FALSE, license character varying(32), sequence integer DEFAULT 100, - auto_installable boolean default False, + auto_install boolean default False, primary key(id) ); ALTER TABLE ir_module_module add constraint name_uniq unique (name); diff --git a/openerp/addons/base/module/module.py b/openerp/addons/base/module/module.py index 808a89f6120..75936146574 100644 --- a/openerp/addons/base/module/module.py +++ b/openerp/addons/base/module/module.py @@ -192,7 +192,7 @@ class module(osv.osv): 'sequence': fields.integer('Sequence'), 'dependencies_id': fields.one2many('ir.module.module.dependency', 'module_id', 'Dependencies', readonly=True), - 'auto_installable': fields.boolean('Auto Installable', + '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.'), @@ -329,7 +329,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_installable', '=', 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) @@ -450,7 +450,7 @@ class module(osv.osv): 'complexity': terp.get('complexity', ''), 'sequence': terp.get('sequence', 100), 'application': terp.get('application', False), - 'auto_installable': terp.get('auto_installable', False), + 'auto_install': terp.get('auto_install', False), } # update the list of available packages diff --git a/openerp/modules/db.py b/openerp/modules/db.py index df25013ecf3..c8ac6d821f2 100644 --- a/openerp/modules/db.py +++ b/openerp/modules/db.py @@ -66,7 +66,7 @@ def initialize(cr): category_id = create_categories(cr, categories) if info['installable']: - if info['auto_installable'] and not info['depends']: + if info['auto_install'] and not info['depends']: state = 'to install' else: state = 'uninstalled' @@ -75,12 +75,12 @@ def initialize(cr): cr.execute('INSERT INTO ir_module_module \ (author, website, name, shortdesc, description, \ - category_id, auto_installable, state, certificate, web, license, complexity, application, icon, sequence) \ + 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, - info['auto_installable'], state, info['certificate'], + info['auto_install'], state, info['certificate'], info['web'], info['license'], info['complexity'], info['application'], info['icon'], diff --git a/openerp/modules/module.py b/openerp/modules/module.py index acf883c2158..a731ae63b30 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -327,7 +327,7 @@ def load_information_from_description_file(module): 'description': '', 'icon': get_module_icon(module), 'installable': True, - 'auto_installable': False, + 'auto_install': False, 'license': 'AGPL-3', 'name': False, 'post_load': None, From c447ac4b9ac9fc00f4f79815d0cad2f8559dcf4e Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 30 Jan 2012 10:53:07 +0100 Subject: [PATCH 3/6] [IMP] manifest: removed the Hidden/Links category. bzr revid: vmt@openerp.com-20120130095307-cqhysxf6pzovikog --- openerp/addons/base/module/module_data.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/openerp/addons/base/module/module_data.xml b/openerp/addons/base/module/module_data.xml index 5cf66064a9e..ec5f8aa42af 100644 --- a/openerp/addons/base/module/module_data.xml +++ b/openerp/addons/base/module/module_data.xml @@ -7,13 +7,6 @@ - - - Links - 0 - - - Localization From 15a8f081706f5714c8b0e9d8c87d8cc0d26edf17 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 30 Jan 2012 11:20:41 +0100 Subject: [PATCH 4/6] [IMP] manifest: renamed active to auto_install. bzr revid: vmt@openerp.com-20120130102041-aensqjeqkftq8nm5 --- openerp/tests/addons/test_exceptions/__openerp__.py | 2 +- openerp/tests/addons/test_limits/__openerp__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openerp/tests/addons/test_exceptions/__openerp__.py b/openerp/tests/addons/test_exceptions/__openerp__.py index bac853e301a..183f8877577 100644 --- a/openerp/tests/addons/test_exceptions/__openerp__.py +++ b/openerp/tests/addons/test_exceptions/__openerp__.py @@ -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: diff --git a/openerp/tests/addons/test_limits/__openerp__.py b/openerp/tests/addons/test_limits/__openerp__.py index 333f1fe4372..05b70919a2a 100644 --- a/openerp/tests/addons/test_limits/__openerp__.py +++ b/openerp/tests/addons/test_limits/__openerp__.py @@ -10,6 +10,6 @@ 'depends': ['base'], 'data': [], 'installable': True, - 'active': False, + 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From c22e8190da2bf05bd4ed8ffebfb3ac8f7b3179e2 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 30 Jan 2012 12:31:16 +0100 Subject: [PATCH 5/6] [IMP] manifest: still support the old `active` entry (but deprecate it and display a warning). bzr revid: vmt@openerp.com-20120130113116-msjaej7jxp96tbvh --- openerp/modules/module.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openerp/modules/module.py b/openerp/modules/module.py index a731ae63b30..7f59f15a08d 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -48,6 +48,8 @@ import logging 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 @@ def load_information_from_description_file(module): 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', @@ -343,6 +344,12 @@ def load_information_from_description_file(module): 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 From 89e411fb39d81862cab872aa4be4cdb229e22495 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Mon, 30 Jan 2012 22:04:29 +0100 Subject: [PATCH 6/6] remove warning bzr revid: al@openerp.com-20120130210429-zw7aziwhkhi0yhqv --- openerp/modules/module.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openerp/modules/module.py b/openerp/modules/module.py index 7f59f15a08d..2d8ce0abd27 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -321,6 +321,7 @@ def load_information_from_description_file(module): info = { 'application': False, 'author': '', + 'auto_install': False, 'category': 'Uncategorized', 'certificate': None, 'complexity': 'normal', @@ -345,9 +346,7 @@ def load_information_from_description_file(module): 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) + # 'active' has been renamed 'auto_install' info['auto_install'] = info['active'] return info