From 89eb1140918c7389a2d67e189b96a8a5697cbe6b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 9 Dec 2011 12:40:02 +0100 Subject: [PATCH 1/4] [ADD] API for immediate installation of modules (modules kanban view), buttons everywhere, remove weird kanban image fallback bzr revid: xmo@openerp.com-20111209114002-dlz79hxft05bhnqx --- openerp/addons/base/module/module.py | 14 +++++++++++++- openerp/addons/base/module/module_view.xml | 11 ++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/openerp/addons/base/module/module.py b/openerp/addons/base/module/module.py index 5db21282c65..a2fa5084c39 100644 --- a/openerp/addons/base/module/module.py +++ b/openerp/addons/base/module/module.py @@ -321,7 +321,19 @@ class module(osv.osv): def button_install(self, cr, uid, ids, context=None): self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context) return dict(ACTION_DICT, name=_('Install')) - + + def button_immediate_install(self, cr, uid, ids, context=None): + """ Installs the selected module(s) immediately and fully, + returns the next res.config action to execute + + :param ids: identifiers of the modules to install + :returns: next res.config item to execute + :rtype: dict[str, object] + """ + self.state_update(cr, uid, ids, 'to install', ['uninstalled'], context) + cr.commit() + db, pool = pooler.restart_pool(cr.dbname, update_module=True) + return pool.get('res.config').next(db.cursor(), uid, [], context=context) def button_install_cancel(self, cr, uid, ids, context=None): self.write(cr, uid, ids, {'state': 'uninstalled', 'demo':False}) diff --git a/openerp/addons/base/module/module_view.xml b/openerp/addons/base/module/module_view.xml index 76aec91b98e..99468493814 100644 --- a/openerp/addons/base/module/module_view.xml +++ b/openerp/addons/base/module/module_view.xml @@ -70,8 +70,9 @@ + - +

@@ -79,13 +80,9 @@
Complex

- Install - + +
-
From 80de80c7dd0bccf2963faef39b29b668b28f039f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 9 Dec 2011 12:53:16 +0100 Subject: [PATCH 2/4] [IMP] reduce noise in setting default values of module descriptor file bzr revid: xmo@openerp.com-20111209115316-2gqwmn2pi34vzu29 --- openerp/modules/module.py | 46 ++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/openerp/modules/module.py b/openerp/modules/module.py index 78f1f831920..4b9771636c7 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -231,9 +231,32 @@ def load_information_from_description_file(module): if terp_file: info = {} 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', + 'certificate': None, + 'complexity': 'normal', + 'depends': [], + 'description': '', + 'icon': None, + 'installable': True, + 'license': 'AGPL-3', + 'name': False, + 'post_load': None, + 'version': '0.0.0', + 'web': False, + 'website': '', + } + info.update(itertools.izip( + 'depends data demo test init_xml update_xml demo_xml'.split(), + iter(list, None))) + terp_f = tools.file_open(terp_file) try: - info = eval(terp_f.read()) + info.update(eval(terp_f.read())) except Exception: logger.notifyChannel('modules', netsvc.LOG_ERROR, 'module %s: exception while evaluating file %s' % @@ -241,27 +264,6 @@ def load_information_from_description_file(module): raise finally: terp_f.close() - # TODO the version should probably be mandatory - info.setdefault('version', '0') - info.setdefault('category', 'Uncategorized') - info.setdefault('depends', []) - info.setdefault('author', '') - info.setdefault('website', '') - info.setdefault('name', False) - info.setdefault('description', '') - info.setdefault('complexity', 'normal') - info.setdefault('application', False) - info.setdefault('icon', 'images/icon.png') - info['certificate'] = info.get('certificate') or None - info['web'] = info.get('web') or False - info['license'] = info.get('license') or 'AGPL-3' - info.setdefault('installable', True) - info.setdefault('active', False) - # If the following is provided, it is called after the module is --loaded. - info.setdefault('post_load', None) - for kind in ['data', 'demo', 'test', - 'init_xml', 'update_xml', 'demo_xml']: - info.setdefault(kind, []) return info #TODO: refactor the logger in this file to follow the logging guidelines From c25475879c1f2af06899bcef8f9c32ced93bc192 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 9 Dec 2011 13:02:07 +0100 Subject: [PATCH 3/4] [IMP] opening and getting data from module description file bzr revid: xmo@openerp.com-20111209120207-3kkyvwedbjez29rl --- openerp/modules/module.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/openerp/modules/module.py b/openerp/modules/module.py index 4b9771636c7..899fa6efece 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -254,16 +254,9 @@ def load_information_from_description_file(module): 'depends data demo test init_xml update_xml demo_xml'.split(), iter(list, None))) - terp_f = tools.file_open(terp_file) - try: + with tools.file_open(terp_file) as terp_f: info.update(eval(terp_f.read())) - except Exception: - logger.notifyChannel('modules', netsvc.LOG_ERROR, - 'module %s: exception while evaluating file %s' % - (module, terp_file)) - raise - finally: - terp_f.close() + return info #TODO: refactor the logger in this file to follow the logging guidelines From 9e94b86bfe3713ab65bcf204faffcb5d43746541 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 9 Dec 2011 13:28:03 +0100 Subject: [PATCH 4/4] [IMP] icon management in modules * If icon is present in descriptor file, use that path * Else try to find #{module}/static/src/img/icon.png * Else fallback on /base/static/src/img/icon.png bzr revid: xmo@openerp.com-20111209122803-elwonegpl8kut7pf --- .../static/src/img/{kanban_partner.png => icon.png} | Bin openerp/modules/module.py | 7 ++++++- 2 files changed, 6 insertions(+), 1 deletion(-) rename openerp/addons/base/static/src/img/{kanban_partner.png => icon.png} (100%) diff --git a/openerp/addons/base/static/src/img/kanban_partner.png b/openerp/addons/base/static/src/img/icon.png similarity index 100% rename from openerp/addons/base/static/src/img/kanban_partner.png rename to openerp/addons/base/static/src/img/icon.png diff --git a/openerp/modules/module.py b/openerp/modules/module.py index 899fa6efece..7f934275894 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -218,6 +218,11 @@ def get_module_resource(module, *args): return resource_path return False +def get_module_icon(module): + iconpath = ['static', 'src', 'img', 'icon.png'] + if get_module_resource(module, *iconpath): + return ('/' + module + '/') + '/'.join(iconpath) + return '/base/' + '/'.join(iconpath) def load_information_from_description_file(module): """ @@ -241,7 +246,7 @@ def load_information_from_description_file(module): 'complexity': 'normal', 'depends': [], 'description': '', - 'icon': None, + 'icon': get_module_icon(module), 'installable': True, 'license': 'AGPL-3', 'name': False,