[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
This commit is contained in:
Thibault Delavallée 2014-05-12 13:41:49 +02:00
parent 443c830bfc
commit 9199587ec9
10 changed files with 50 additions and 153 deletions

View File

@ -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

View File

@ -79,7 +79,6 @@
<field name="help">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.</field>
</record>
<!-- Case Sections Salesteams kanban view -->
<record model="ir.ui.view" id="crm_case_section_salesteams_view_kanban">
<field name="name">crm.case.section.kanban</field>
<field name="model">crm.case.section</field>
@ -94,15 +93,6 @@
<small><span class="oe_e oe_e_alias" style="float: none;">%%</span><t t-raw="record.alias_id.raw_value[1]"/></small>
</div>
</xpath>
</data>
</field>
</record>
<record model="ir.ui.view" id="crm_case_section_salesteams_view_kanban">
<field name="name">crm.case.section.kanban</field>
<field name="model">crm.case.section</field>
<field name="inherit_id" ref="sales_team.crm_case_section_salesteams_view_kanban"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='name']" position="after">
<field name="use_leads"/>
<field name="monthly_open_leads"/>
@ -130,8 +120,41 @@
</field>
</record>
<!-- Case Sections Action -->
<record model="ir.ui.view" id="sales_team_form_view_in_crm">
<field name="name">crm.case.section.form</field>
<field name="model">crm.case.section</field>
<field name="inherit_id" ref="sales_team.crm_case_section_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<h6><field name="use_leads"/><label for="use_leads" string="Leads"/></h6>
</xpath>
<xpath expr="//group/field[@name='active']" position="inside">
<group>
<label for="alias_name" string="Email Alias"
attrs="p'invisible': [('alias_domain', '=', False)]}"/>
<div name="alias_def"
attrs="{'invisible': [('alias_domain', '=', False)]}">
<field name="alias_id" class="oe_read_only oe_inline"
string="Email Alias" required="0"/>
<div class="oe_edit_only oe_inline" name="edit_alias" style="display: inline;" >
<field name="alias_name" class="oe_inline"/>@<field name="alias_domain" class="oe_inline" readonly="1"/>
</div>
</div>
<field name="alias_contact" class="oe_inline"
string="Accept Emails From"
attrs="{'invisible': [('alias_domain', '=', False)]}"/>
</group>
</xpath>
<xpath expr="//page[@string='Team Members']" position="after">
<page string="Stages">
<separator string="Select Stages for this Sales Team"/>
<field name="stage_ids"/>
</page>
</xpath>
</field>
</record>
<!-- Case Sections Action -->
<record model="ir.actions.act_window.view" id="action_crm_tag_kanban_view_salesteams_oppor11">
<field name="sequence" eval="0"/>
<field name="view_mode">kanban</field>
@ -160,39 +183,5 @@
<field name="view_type">tree</field>
<field name="view_id" ref="sales_team.crm_case_section_view_tree"/>
</record>
<record model="ir.ui.view" id="sales_team_form_view_in_crm">
<field name="name">crm.case.section.form</field>
<field name="model">crm.case.section</field>
<field name="inherit_id" ref="sales_team.crm_case_section_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<h6><field name="use_leads"/><label for="use_leads" string="Leads"/></h6>
</xpath>
<xpath expr="//group/field[@name='active']" position="inside">
<group>
<label for="alias_name" string="Email Alias"
attrs="p'invisible': [('alias_domain', '=', False)]}"/>
<div name="alias_def"
attrs="{'invisible': [('alias_domain', '=', False)]}">
<field name="alias_id" class="oe_read_only oe_inline"
string="Email Alias" required="0"/>
<div class="oe_edit_only oe_inline" name="edit_alias" style="display: inline;" >
<field name="alias_name" class="oe_inline"/>@<field name="alias_domain" class="oe_inline" readonly="1"/>
</div>
</div>
<field name="alias_contact" class="oe_inline"
string="Accept Emails From"
attrs="{'invisible': [('alias_domain', '=', False)]}"/>
</group>
</xpath>
<xpath expr="//page[@string='Team Members']" position="after">
<page string="Stages">
<separator string="Select Stages for this Sales Team"/>
<field name="stage_ids"/>
</page>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -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:

View File

@ -54,7 +54,7 @@ Could you please send me the details ?</field>
<field name="type_id" ref="type_lead7"/>
<field name="categ_ids" eval="[(6, 0, [categ_oppor2])]"/>
<field name="channel_id" ref="crm_case_channel_website"/>
<field name="priority">4</field>
<field name="priority">1</field>
<field name="section_id" ref="sales_team.section_sales_department"/>
<field name="user_id" ref="base.user_root"/>
<field name="stage_id" ref="stage_lead1"/>
@ -104,7 +104,7 @@ Could you please send me the details ?</field>
<field name="type_id" ref="type_lead8"/>
<field name="categ_ids" eval="[(6, 0, [categ_oppor5])]"/>
<field name="channel_id" ref=""/>
<field name="priority">3</field>
<field name="priority">2</field>
<field name="section_id" ref="sales_team.crm_case_section_2"/>
<field name="user_id" ref="base.user_demo"/>
<field name="stage_id" ref="stage_lead6"/>
@ -129,7 +129,7 @@ Could you please send me the details ?</field>
<field name="type_id" ref="type_lead3"/>
<field name="categ_ids" eval="[(6, 0, [categ_oppor1])]"/>
<field name="channel_id" ref="crm_case_channel_website"/>
<field name="priority">3</field>
<field name="priority">2</field>
<field name="section_id" ref="sales_team.crm_case_section_1"/>
<field name="user_id" ref=""/>
<field name="stage_id" ref="stage_lead1"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<openerp>
<data>
<!-- TODO: Apply group for the sales team where you find section_id fields in any view
<!--
CRM CASE STAGE
-->
<!-- Stage Search view -->

View File

@ -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",

View File

@ -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

View File

@ -19,6 +19,6 @@
#
##############################################################################
import sales_team
import sales_team_config
import res_config
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,30 +1,11 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-today OpenERP SA (<http://www.openerp.com>)
#
# 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/>.
#
##############################################################################
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
}

View File

@ -1,49 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record id="base.group_sale_salesman" model="res.groups">
<field name="name">User: Own Leads Only</field>
<field name="category_id" ref="base.module_category_sales_management"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
<field name="comment">the user will have access to his own data in the sales application.</field>
</record>
<record id="base.group_sale_salesman_all_leads" model="res.groups">
<field name="name">User: All Leads</field>
<field name="category_id" ref="base.module_category_sales_management"/>
<field name="implied_ids" eval="[(4, ref('base.group_sale_salesman'))]"/>
<field name="comment">the user will have access to all records of everyone in the sales application.</field>
</record>
<record id="base.group_sale_manager" model="res.groups">
<field name="name">Manager</field>
<field name="comment">the user will have an access to the sales configuration as well as statistic reports.</field>
<field name="category_id" ref="base.module_category_sales_management"/>
<field name="implied_ids" eval="[(4, ref('base.group_sale_salesman_all_leads'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
<record id="base.group_mono_salesteams" model="res.groups">
<field name="name">Do Not Use Sales Teams</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="base.group_user" model="res.groups">
<field name="implied_ids" eval="[(4, ref('base.group_mono_salesteams'))]"/>
</record>
<record id="base.group_multi_salesteams" model="res.groups">
<field name="name">Manage Sales Teams</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record model="res.users" id="base.user_root">
<field eval="[(4,ref('base.group_partner_manager'))]" name="groups_id"/>
</record>
<record model='ir.ui.menu' id='base.menu_base_partner'>
<field name="groups_id" eval="[(4,ref('base.group_sale_manager')),(4,ref('base.group_sale_salesman'))]"/>
</record>
<record model="ir.ui.menu" id="base.menu_base_config">
<field eval="[(4, ref('base.group_sale_manager'))]" name="groups_id"/>
</record>
</data>
</openerp>