From 9199587ec99929777cd41270693e8e84a844fc80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 12 May 2014 13:41:49 +0200 Subject: [PATCH] [CLEAN] crm: cleaned crm module before merging : - removed unnecessary changes - rewrote on_change_user and get_default_sectoin_id to have a correct default section - removed duplicated code in sales_team module due to code moving not correctly cleaned --- addons/crm/__init__.py | 2 +- addons/crm/crm_case_section_view.xml | 79 ++++++++----------- addons/crm/crm_lead.py | 11 ++- addons/crm/crm_lead_demo.xml | 6 +- addons/crm/crm_lead_view.xml | 2 +- addons/crm/res_config.py | 30 ------- .../{crm_case_section.py => sales_team.py} | 1 - addons/sales_team/__init__.py | 2 +- .../{sales_team_config.py => res_config.py} | 30 +------ .../security/sales_team_security.xml | 40 +--------- 10 files changed, 50 insertions(+), 153 deletions(-) rename addons/crm/{crm_case_section.py => sales_team.py} (99%) rename addons/sales_team/{sales_team_config.py => res_config.py} (59%) diff --git a/addons/crm/__init__.py b/addons/crm/__init__.py index aac80a22695..872d0390303 100644 --- a/addons/crm/__init__.py +++ b/addons/crm/__init__.py @@ -22,7 +22,7 @@ import crm import crm_segmentation import crm_lead -import crm_case_section +import sales_team import calendar_event import crm_phonecall import report diff --git a/addons/crm/crm_case_section_view.xml b/addons/crm/crm_case_section_view.xml index cc6aba3c408..8be2d888fb6 100644 --- a/addons/crm/crm_case_section_view.xml +++ b/addons/crm/crm_case_section_view.xml @@ -79,7 +79,6 @@ Opportunities Analysis gives you an instant access to your opportunities with information such as the expected revenue, planned cost, missed deadlines or the number of interactions per opportunity. This report is mainly used by the sales manager in order to do the periodic review with the teams of the sales pipeline. - crm.case.section.kanban crm.case.section @@ -94,15 +93,6 @@ %% - - - - - crm.case.section.kanban - crm.case.section - - - @@ -130,8 +120,41 @@ - + + crm.case.section.form + crm.case.section + + + +
+
+ + + + + + + + + + +
+
+ kanban @@ -160,39 +183,5 @@ tree - - - crm.case.section.form - crm.case.section - - - -
-
- - - - - - - - - - -
-
diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 6be094c2227..7f5ae17dc33 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -90,7 +90,10 @@ class crm_lead(format_address, osv.osv): def _get_default_section_id(self, cr, uid, context=None): """ Gives default section by checking if present in the context """ - return self._resolve_section_id_from_context(cr, uid, context=context) or False + section_id = self._resolve_section_id_from_context(cr, uid, context=context) or False + if not section_id: + section_id = self.pool.get('res.users').browse(cr, uid, uid, context).default_section_id.id or False + return section_id def _get_default_stage_id(self, cr, uid, context=None): """ Gives default stage_id """ @@ -352,12 +355,8 @@ class crm_lead(format_address, osv.osv): section_ids = self.pool.get('crm.case.section').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context) if section_ids: section_id = section_ids[0] - else: - user = self.pool.get('res.users').browse(cr, uid, user_id, context=context) - if user.default_section_id and user.default_section_id.id: - return {'value': {'section_id': user.default_section_id.id}} return {'value': {'section_id': section_id}} - + def stage_find(self, cr, uid, cases, section_id, domain=None, order='sequence', context=None): """ Override of the base.stage method Parameter of the stage search taken from the lead: diff --git a/addons/crm/crm_lead_demo.xml b/addons/crm/crm_lead_demo.xml index ef105d3989e..8acefd5c610 100644 --- a/addons/crm/crm_lead_demo.xml +++ b/addons/crm/crm_lead_demo.xml @@ -54,7 +54,7 @@ Could you please send me the details ? - 4 + 1 @@ -104,7 +104,7 @@ Could you please send me the details ? - 3 + 2 @@ -129,7 +129,7 @@ Could you please send me the details ? - 3 + 2 diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index 3481e29baf5..995a1ddea43 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -1,7 +1,7 @@ - diff --git a/addons/crm/res_config.py b/addons/crm/res_config.py index 1cd31cd0dd0..d48e66e286c 100644 --- a/addons/crm/res_config.py +++ b/addons/crm/res_config.py @@ -27,33 +27,6 @@ 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 add - 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', @@ -64,9 +37,6 @@ class crm_configuration(osv.TransientModel): '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.\n' '-This installs the module crm_helpdesk.'), - 'group_multi_salesteams': fields.boolean("Organize Sales activities into multiple Sales Teams", - implied_group='base.group_multi_salesteams', - help="""Allows you to use Sales Teams to manage your leads and opportunities."""), 'alias_prefix': fields.char('Default Alias Name for Leads'), 'alias_domain' : fields.char('Alias Domain'), 'group_scheduled_calls': fields.boolean("Schedule calls to manage call center", diff --git a/addons/crm/crm_case_section.py b/addons/crm/sales_team.py similarity index 99% rename from addons/crm/crm_case_section.py rename to addons/crm/sales_team.py index 7a8baca5a44..ac626563f36 100644 --- a/addons/crm/crm_case_section.py +++ b/addons/crm/sales_team.py @@ -78,4 +78,3 @@ class crm_case_section(osv.Model): res = super(crm_case_section, self).unlink(cr, uid, ids, context=context) mail_alias.unlink(cr, uid, alias_ids, context=context) return res - diff --git a/addons/sales_team/__init__.py b/addons/sales_team/__init__.py index 075d782f564..3b2a8f41267 100644 --- a/addons/sales_team/__init__.py +++ b/addons/sales_team/__init__.py @@ -19,6 +19,6 @@ # ############################################################################## import sales_team -import sales_team_config +import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/sales_team/sales_team_config.py b/addons/sales_team/res_config.py similarity index 59% rename from addons/sales_team/sales_team_config.py rename to addons/sales_team/res_config.py index 1e2a193acf7..3081a2e918d 100644 --- a/addons/sales_team/sales_team_config.py +++ b/addons/sales_team/res_config.py @@ -1,30 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-today OpenERP SA () -# -# 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 . -# -############################################################################## from openerp.osv import fields, osv class sales_team_configuration(osv.TransientModel): _name = 'sale.config.settings' - _inherit = ['sale.config.settings', 'fetchmail.config.settings'] + _inherit = ['sale.config.settings'] def set_group_multi_salesteams(self, cr, uid, ids, context=None): """ This method is automatically called by res_config as it begins @@ -58,12 +39,3 @@ class sales_team_configuration(osv.TransientModel): implied_group='base.group_multi_salesteams', help="""Allows you to use Sales Teams to manage your leads and opportunities."""), } - - def _get_group_multi_salesteams(self, cr, uid, ids, context=None): - pass - # Todo: return the current state for the group_multi_salesteams field - - _defaults = { - 'group_multi_salesteams': _get_group_multi_salesteams - } - diff --git a/addons/sales_team/security/sales_team_security.xml b/addons/sales_team/security/sales_team_security.xml index fe999715a7a..d9002f8332f 100644 --- a/addons/sales_team/security/sales_team_security.xml +++ b/addons/sales_team/security/sales_team_security.xml @@ -1,49 +1,17 @@ - - - User: Own Leads Only - - - the user will have access to his own data in the sales application. - - - - User: All Leads - - - the user will have access to all records of everyone in the sales application. - - - - Manager - the user will have an access to the sales configuration as well as statistic reports. - - - - - Do Not Use Sales Teams - + + + + Manage Sales Teams - - - - - - - - - - - -