[MERGE] with trunk
[odoo/odoo.git] / addons / crm / res_config.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Business Applications
5 #    Copyright (C) 2004-TODAY OpenERP S.A. (<http://openerp.com>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 from openerp.osv import fields, osv
23
24
25 class crm_configuration(osv.TransientModel):
26     _name = 'sale.config.settings'
27     _inherit = ['sale.config.settings', 'fetchmail.config.settings']
28
29     def set_group_multi_salesteams(self, cr, uid, ids, context=None):
30         """ This method is automatically called by res_config as it begins
31             with set. It is used to implement the 'one group or another'
32             behavior. We have to perform some group manipulation by hand
33             because in res_config.execute(), set_* methods are called
34             after group_*; therefore writing on an hidden res_config file
35             could not work.
36             If group_multi_salesteams is checked: remove group_mono_salesteams
37             from group_user, remove the users. Otherwise, just add
38             group_mono_salesteams in group_user.
39             The inverse logic about group_multi_salesteams is managed by the
40             normal behavior of 'group_multi_salesteams' field.
41         """
42         def ref(xml_id):
43             mod, xml = xml_id.split('.', 1)
44             return self.pool['ir.model.data'].get_object(cr, uid, mod, xml, context)
45
46         for obj in self.browse(cr, uid, ids, context=context):
47             config_group = ref('base.group_mono_salesteams')
48             base_group = ref('base.group_user')
49             if obj.group_multi_salesteams:
50                 base_group.write({'implied_ids': [(3, config_group.id)]})
51                 config_group.write({'users': [(3, u.id) for u in base_group.users]})
52             else:
53                 base_group.write({'implied_ids': [(4, config_group.id)]})
54         return True
55
56     _columns = {
57         'group_fund_raising': fields.boolean("Manage Fund Raising",
58             implied_group='crm.group_fund_raising',
59             help="""Allows you to trace and manage your activities for fund raising."""),
60         'module_crm_claim': fields.boolean("Manage Customer Claims",
61             help="""Allows you to track your customers/suppliers claims and grievances.
62                     This installs the module crm_claim."""),
63         'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support",
64             help="""Allows you to communicate with Customer, process Customer query, and provide better help and support. This installs the module crm_helpdesk."""),
65         'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
66             implied_group='base.group_multi_salesteams',
67             help="""Allows you to use Sales Teams to manage your leads and opportunities."""),
68     }
69
70
71 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: