[IMP]: Improved code.
bzr revid: uco@tinyerp.com-20120224100050-vqi9b4b6q1r8oku8
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
import pooler
|
||||
|
||||
class sale_configuration(osv.osv_memory):
|
||||
_name = 'sale.configuration'
|
||||
@@ -50,34 +51,31 @@ class sale_configuration(osv.osv_memory):
|
||||
|
||||
}
|
||||
|
||||
def default_module_get(self, cr, uid, ids, selectable=[], context=None):
|
||||
#TODO: TO BE IMPLEMENTED
|
||||
modules = self.pool.get('ir.module.module')
|
||||
mods = ['analytic_user_function', 'analytic_journal_billing_rate', 'import_sugarcrm', 'import_google', 'crm_caldav', 'wiki_sale_faq', 'crm_partner_assign', 'plugin_thunderbird', 'plugin_outlook', 'google_map']
|
||||
res = dict([(m,False) for m in mods])
|
||||
for mod in mods:
|
||||
if mod not in selectable:
|
||||
selectable.append(mod)
|
||||
module_ids = modules.search(cr, uid,
|
||||
[('name','in',selectable),
|
||||
def get_applied_groups(self, cr, uid, ids, context=None):
|
||||
groups = {}
|
||||
return groups
|
||||
|
||||
def get_installed_modules(self, cr, uid, modules, context=None):
|
||||
module_obj = self.pool.get('ir.module.module')
|
||||
module_ids = module_obj.search(cr, uid,
|
||||
[('name','in',modules),
|
||||
('state','in',['to install', 'installed', 'to upgrade'])],
|
||||
context=context)
|
||||
|
||||
installed_modules = dict([(mod.name,True) for mod in modules.browse(cr, uid, module_ids, context=context)])
|
||||
res.update(installed_modules)
|
||||
return res
|
||||
installed_modules = dict([(mod.name,True) for mod in module_obj.browse(cr, uid, module_ids, context=context)])
|
||||
return installed_modules
|
||||
|
||||
def default_get(self, cr, uid, fields_list, context=None):
|
||||
result = super(sale_configuration, self).default_get(
|
||||
cr, uid, fields_list, context=context)
|
||||
module_list = ['analytic_user_function', 'analytic_journal_billing_rate', 'import_sugarcrm',
|
||||
'import_google', 'crm_caldav', 'wiki_sale_faq', 'crm_partner_assign',
|
||||
'google_map', 'plugin_thunderbird', 'plugin_outlook']
|
||||
installed_modules = self.get_installed_modules(cr, uid, module_list, context=context)
|
||||
result.update(installed_modules)
|
||||
return result
|
||||
|
||||
_defaults = {
|
||||
'type': 'pop',
|
||||
'google_map': default_module_get,
|
||||
'crm_caldav': default_module_get,
|
||||
'analytic_user_function': default_module_get,
|
||||
'analytic_journal_billing_rate': default_module_get,
|
||||
'import_sugarcrm': default_module_get,
|
||||
'import_google': default_module_get,
|
||||
'wiki_sale_faq': default_module_get,
|
||||
'plugin_thunderbird': default_module_get,
|
||||
'plugin_outlook': default_module_get,
|
||||
}
|
||||
|
||||
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False):
|
||||
@@ -90,11 +88,28 @@ class sale_configuration(osv.osv_memory):
|
||||
else:
|
||||
values['server'] = ''
|
||||
values['port'] = port
|
||||
return {'value':values}
|
||||
return {'value': values}
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
self.execute(cr, uid, ids, context=context)
|
||||
return super(sale_configuration, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
def execute(self, cr, uid, ids, context=None):
|
||||
#TODO: TO BE IMPLEMENTED
|
||||
return {}
|
||||
module_obj = self.pool.get('ir.module.module')
|
||||
wizard = self.read(cr, uid, ids)[0]
|
||||
module_list = ['analytic_user_function', 'analytic_journal_billing_rate', 'import_sugarcrm',
|
||||
'import_google', 'crm_caldav', 'wiki_sale_faq', 'crm_partner_assign',
|
||||
'google_map', 'plugin_thunderbird', 'plugin_outlook']
|
||||
for k, v in wizard.items():
|
||||
if k in module_list and v == True:
|
||||
installed = self.get_installed_modules(cr, uid, [k], context)
|
||||
if not installed:
|
||||
module_id = module_obj.search(cr, uid, [('name','=',k)])[0]
|
||||
module_obj.state_update(cr, uid, [module_id], 'to install', ['uninstalled'], context)
|
||||
cr.commit()
|
||||
pooler.restart_pool(cr.dbname, update_module=True)[1]
|
||||
|
||||
|
||||
sale_configuration()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user