2012-02-29 09:50:21 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
|
|
|
#
|
2012-04-03 08:44:25 +00:00
|
|
|
# OpenERP, Open Source Business Applications
|
2013-03-28 09:55:02 +00:00
|
|
|
# Copyright (C) 2004-TODAY OpenERP S.A. (<http://openerp.com>).
|
2012-02-29 09:50:21 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2014-02-12 10:31:48 +00:00
|
|
|
from openerp import SUPERUSER_ID
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
2012-02-29 09:50:21 +00:00
|
|
|
|
2013-03-28 09:55:02 +00:00
|
|
|
|
|
|
|
class crm_configuration(osv.TransientModel):
|
2012-03-26 12:07:00 +00:00
|
|
|
_name = 'sale.config.settings'
|
|
|
|
_inherit = ['sale.config.settings', 'fetchmail.config.settings']
|
2012-02-29 09:50:21 +00:00
|
|
|
|
2013-03-28 16:07:04 +00:00
|
|
|
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'
|
2013-09-03 09:02:46 +00:00
|
|
|
behavior. We have to perform some group manipulation by hand
|
2013-03-28 16:07:04 +00:00
|
|
|
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
|
[MERGE] Alias Visibility and Salesteams View. Improve the display of alias in form views and in empty list help messages. Improve the use, visibility and display of salesteams.
This revision adds a configuration in Settings/Sales: enable the use of sales team. If not enabled, users have access to Leads and Opportunities menus; Sales Teams menu is hidden, as well as all fields related to sales teams. If enabled, a Sales Teams menu is added that works as the Project menu. The new sales Teams kanban view allows to have an overview of the sales team (leads, opportunities, quotations, sales orders, invoices). Clicking on a link of the kanban vignette redirect to the related list/kanban view, filtered by the chosen sales team.
This revision also improves the display of help message (also shown for empty kanban views) for leads, opportunities, tasks, issues, applicants. It displays the current sales team / project / job alias, or a default alias if no context is provided.
bzr revid: tde@openerp.com-20130405151914-8892yfmsmr2xwbbk
2013-04-05 15:19:14 +00:00
|
|
|
from group_user, remove the users. Otherwise, just add
|
2013-03-28 16:07:04 +00:00
|
|
|
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
|
|
|
|
|
2012-02-29 09:50:21 +00:00
|
|
|
_columns = {
|
2012-07-31 11:16:45 +00:00
|
|
|
'group_fund_raising': fields.boolean("Manage Fund Raising",
|
|
|
|
implied_group='crm.group_fund_raising',
|
|
|
|
help="""Allows you to trace and manage your activities for fund raising."""),
|
2013-03-28 09:55:02 +00:00
|
|
|
'module_crm_claim': fields.boolean("Manage Customer Claims",
|
2013-07-24 13:45:48 +00:00
|
|
|
help='Allows you to track your customers/suppliers claims and grievances.\n'
|
2013-09-17 13:08:14 +00:00
|
|
|
'-This installs the module crm_claim.'),
|
2013-03-28 09:55:02 +00:00
|
|
|
'module_crm_helpdesk': fields.boolean("Manage Helpdesk and Support",
|
2013-08-30 10:45:24 +00:00
|
|
|
help='Allows you to communicate with Customer, process Customer query, and provide better help and support.\n'
|
|
|
|
'-This installs the module crm_helpdesk.'),
|
2013-04-04 11:55:40 +00:00
|
|
|
'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams",
|
2013-03-28 09:55:02 +00:00
|
|
|
implied_group='base.group_multi_salesteams',
|
|
|
|
help="""Allows you to use Sales Teams to manage your leads and opportunities."""),
|
2013-12-20 11:00:45 +00:00
|
|
|
'alias_prefix': fields.char('Default Alias Name for Leads'),
|
|
|
|
'alias_domain' : fields.char('Alias Domain'),
|
2014-03-10 13:18:47 +00:00
|
|
|
'group_scheduled_calls_menu': fields.boolean("Schedule calls to manage call center",
|
2014-03-04 06:17:38 +00:00
|
|
|
implied_group='crm.group_scheduled_calls_menu',
|
2014-03-10 13:18:47 +00:00
|
|
|
help="""This adds menu 'Scheduled Calls' under 'Sales / Phone Calls'""")
|
2012-02-29 09:50:21 +00:00
|
|
|
}
|
2012-03-01 11:38:35 +00:00
|
|
|
|
2013-12-27 09:25:06 +00:00
|
|
|
_defaults = {
|
2014-02-12 10:31:48 +00:00
|
|
|
'alias_domain': lambda self, cr, uid, context: self.pool['mail.alias']._get_alias_domain(cr, SUPERUSER_ID, [1], None, None)[1],
|
2013-12-27 09:25:06 +00:00
|
|
|
}
|
|
|
|
|
2014-02-12 10:31:48 +00:00
|
|
|
def _find_default_lead_alias_id(self, cr, uid, context=None):
|
|
|
|
alias_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'crm.mail_alias_lead_info')
|
|
|
|
if not alias_id:
|
|
|
|
alias_ids = self.pool['mail.alias'].search(
|
|
|
|
cr, uid, [
|
|
|
|
('alias_model_id.model', '=', 'crm.lead'),
|
2014-02-13 11:28:11 +00:00
|
|
|
('alias_force_thread_id', '=', False),
|
2014-02-12 10:31:48 +00:00
|
|
|
('alias_parent_model_id.model', '=', 'crm.case.section'),
|
2014-02-13 11:28:11 +00:00
|
|
|
('alias_parent_thread_id', '=', False),
|
2014-02-12 10:31:48 +00:00
|
|
|
('alias_defaults', '=', '{}')
|
|
|
|
], context=context)
|
|
|
|
alias_id = alias_ids and alias_ids[0] or False
|
|
|
|
return alias_id
|
|
|
|
|
2013-12-20 11:00:45 +00:00
|
|
|
def get_default_alias_prefix(self, cr, uid, ids, context=None):
|
2014-02-12 10:31:48 +00:00
|
|
|
alias_name = False
|
|
|
|
alias_id = self._find_default_lead_alias_id(cr, uid, context=context)
|
|
|
|
if alias_id:
|
|
|
|
alias_name = self.pool['mail.alias'].browse(cr, uid, alias_id, context=context).alias_name
|
2013-12-20 11:00:45 +00:00
|
|
|
return {'alias_prefix': alias_name}
|
2013-03-28 16:07:04 +00:00
|
|
|
|
2013-12-20 11:00:45 +00:00
|
|
|
def set_default_alias_prefix(self, cr, uid, ids, context=None):
|
2014-02-12 10:31:48 +00:00
|
|
|
mail_alias = self.pool['mail.alias']
|
|
|
|
for record in self.browse(cr, uid, ids, context=context):
|
|
|
|
alias_id = self._find_default_lead_alias_id(cr, uid, context=context)
|
|
|
|
if not alias_id:
|
|
|
|
create_ctx = dict(context, alias_model_name='crm.lead', alias_parent_model_name='crm.case.section')
|
|
|
|
alias_id = self.pool['mail.alias'].create(cr, uid, {'alias_name': record.alias_prefix}, context=create_ctx)
|
|
|
|
else:
|
|
|
|
mail_alias.write(cr, uid, alias_id, {'alias_name': record.alias_prefix}, context=context)
|
2013-12-20 11:00:45 +00:00
|
|
|
return True
|