From 182b140010558e0fe6d38be3fd9b76129615d2d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 28 Mar 2013 17:07:04 +0100 Subject: [PATCH] [REF] crm: res_config refactored: located in crm/res_config, viewx in res_config_view, using a set_ method to manage two groups. bzr revid: tde@openerp.com-20130328160704-ktp7btaswjiyyc6s --- addons/crm/res_config.py | 32 ++++++++++++++++++++++++++-- addons/crm/res_config_view.xml | 8 +++++++ addons/crm/security/crm_security.xml | 8 +++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py index 5aac7c61fa2..42b08fb2f48 100644 --- a/addons/crm/res_config.py +++ b/addons/crm/res_config.py @@ -26,6 +26,33 @@ class crm_configuration(osv.TransientModel): _name = 'sale.config.settings' _inherit = ['sale.config.settings', 'fetchmail.config.settings'] + def set_group_multi_salesteams(self, cr, uid, ids, context=None): + """ This method is automatically called by res_config as it begins + with set. It is used to implement the 'one group or another' + behavior. We have to perform some group manipulation by hand + because in res_config.execute(), set_* methods are called + after group_*; therefore writing on an hidden res_config file + could not work. + If group_multi_salesteams is checked: remove group_mono_salesteams + from group_user, remove the users. Otherwise, just ass + group_mono_salesteams in group_user. + The inverse logic about group_multi_salesteams is managed by the + normal behavior of 'group_multi_salesteams' field. + """ + def ref(xml_id): + mod, xml = xml_id.split('.', 1) + return self.pool['ir.model.data'].get_object(cr, uid, mod, xml, context) + + for obj in self.browse(cr, uid, ids, context=context): + config_group = ref('base.group_mono_salesteams') + base_group = ref('base.group_user') + if obj.group_multi_salesteams: + base_group.write({'implied_ids': [(3, config_group.id)]}) + config_group.write({'users': [(3, u.id) for u in base_group.users]}) + else: + base_group.write({'implied_ids': [(4, config_group.id)]}) + return True + _columns = { 'group_fund_raising': fields.boolean("Manage Fund Raising", implied_group='crm.group_fund_raising', @@ -34,10 +61,11 @@ class crm_configuration(osv.TransientModel): help="""Allows you to track your customers/suppliers claims and grievances. This installs the module crm_claim."""), 'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support", - help="""Allows you to communicate with Customer, process Customer query, and provide better help and support. This installs the module crm_helpdesk."""), - 'group_multi_salesteams': fields.boolean("Manage Sales Teams", + help="""Allows you to communicate with Customer, process Customer query, and provide better help and support. This installs the module crm_helpdesk."""), + 'group_multi_salesteams': fields.boolean("Use Sales Teams", implied_group='base.group_multi_salesteams', help="""Allows you to use Sales Teams to manage your leads and opportunities."""), } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/res_config_view.xml b/addons/crm/res_config_view.xml index a6ec87b8243..1c460a12422 100644 --- a/addons/crm/res_config_view.xml +++ b/addons/crm/res_config_view.xml @@ -22,6 +22,14 @@ + + + diff --git a/addons/crm/security/crm_security.xml b/addons/crm/security/crm_security.xml index c51c00f0b88..34137dc0fac 100644 --- a/addons/crm/security/crm_security.xml +++ b/addons/crm/security/crm_security.xml @@ -23,6 +23,14 @@ + + Do Not Use Sales Teams + + + + + + Manage Sales Teams