From 4b3c2c7514a24b73991cc4949d36906c035ed4fc Mon Sep 17 00:00:00 2001 From: "Rucha (Open ERP)" Date: Wed, 16 Mar 2011 17:34:44 +0530 Subject: [PATCH] [IMP]: res_config: Improvement for the main application: like HR, we want them to be able to re-thick an installed application but in HRs configuration, if hr_holidays is already installed, the boolean "holidays management" should be thick and readonly bzr revid: rpa@tinyerp.com-20110316120444-vqllngptthlfmeo5 --- openerp/addons/base/res/res_config.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/openerp/addons/base/res/res_config.py b/openerp/addons/base/res/res_config.py index 748405b8473..e9d7867237b 100644 --- a/openerp/addons/base/res/res_config.py +++ b/openerp/addons/base/res/res_config.py @@ -355,6 +355,35 @@ class res_config_installer(osv.osv_memory): return (base | hooks_results | additionals) - set( map(attrgetter('name'), self._already_installed(cr, uid, context))) + def default_get(self, cr, uid, fields_list, context=None): + ''' If an addon is already installed, check it by default + ''' + defaults = super(res_config_installer, self).default_get( + cr, uid, fields_list, context=context) + + return dict(defaults, + **dict.fromkeys( + map(attrgetter('name'), + self._already_installed(cr, uid, context=context)), + True)) + + def fields_get(self, cr, uid, fields=None, context=None, write_access=True): + """ If an addon is already installed, set it to readonly as + res.config.installer doesn't handle uninstallations of already + installed addons + """ + fields = super(res_config_installer, self).fields_get( + cr, uid, fields, context, write_access) + + for module in self._already_installed(cr, uid, context=context): + if module.name not in fields: + continue + fields[module.name].update( + readonly=True, + help= ustr(fields[module.name].get('help', '')) + + _('\n\nThis addon is already installed on your system')) + return fields + def execute(self, cr, uid, ids, context=None): modules = self.pool.get('ir.module.module') to_install = list(self.modules_to_install(