[CLEAN] crm: cleaned crm module before merging :
authorThibault Delavallée <tde@openerp.com>
Mon, 12 May 2014 11:41:49 +0000 (13:41 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 12 May 2014 11:41:49 +0000 (13:41 +0200)
- 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

12 files changed:
addons/crm/__init__.py
addons/crm/crm_case_section.py [deleted file]
addons/crm/crm_case_section_view.xml
addons/crm/crm_lead.py
addons/crm/crm_lead_demo.xml
addons/crm/crm_lead_view.xml
addons/crm/res_config.py
addons/crm/sales_team.py [new file with mode: 0644]
addons/sales_team/__init__.py
addons/sales_team/res_config.py [new file with mode: 0644]
addons/sales_team/sales_team_config.py [deleted file]
addons/sales_team/security/sales_team_security.xml

index aac80a2..872d039 100644 (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
diff --git a/addons/crm/crm_case_section.py b/addons/crm/crm_case_section.py
deleted file mode 100644 (file)
index 7a8baca..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-import calendar
-from datetime import date
-from dateutil import relativedelta
-
-from openerp import tools
-from openerp.osv import fields, osv
-
-
-class crm_case_section(osv.Model):
-    _inherit = 'crm.case.section'
-    _inherits = {'mail.alias': 'alias_id'}
-
-    def _get_opportunities_data(self, cr, uid, ids, field_name, arg, context=None):
-        """ Get opportunities-related data for salesteam kanban view
-            monthly_open_leads: number of open lead during the last months
-            monthly_planned_revenue: planned revenu of opportunities during the last months
-        """
-        obj = self.pool.get('crm.lead')
-        res = dict.fromkeys(ids, False)
-        month_begin = date.today().replace(day=1)
-        date_begin = month_begin - relativedelta.relativedelta(months=self._period_number - 1)
-        date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1])
-        lead_pre_domain = [('create_date', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)),
-                ('create_date', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)),
-                              ('type', '=', 'lead')]
-        opp_pre_domain = [('date_deadline', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)),
-                      ('date_deadline', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)),
-                      ('type', '=', 'opportunity')]
-        for id in ids:
-            res[id] = dict()
-            lead_domain = lead_pre_domain + [('section_id', '=', id)]
-            opp_domain = opp_pre_domain + [('section_id', '=', id)]
-            res[id]['monthly_open_leads'] = self.__get_bar_values(cr, uid, obj, lead_domain, ['create_date'], 'create_date_count', 'create_date', context=context)
-            res[id]['monthly_planned_revenue'] = self.__get_bar_values(cr, uid, obj, opp_domain, ['planned_revenue', 'date_deadline'], 'planned_revenue', 'date_deadline', context=context)
-        return res
-
-    _columns = {
-        'resource_calendar_id': fields.many2one('resource.calendar', "Working Time", help="Used to compute open days"),
-        'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
-        'use_leads': fields.boolean('Leads',
-            help="The first contact you get with a potential customer is a lead you qualify before converting it into a real business opportunity. Check this box to manage leads in this sales team."),
-        'monthly_open_leads': fields.function(_get_opportunities_data,
-            type="string", readonly=True, multi='_get_opportunities_data',
-            string='Open Leads per Month'),
-        'monthly_planned_revenue': fields.function(_get_opportunities_data,
-            type="string", readonly=True, multi='_get_opportunities_data',
-            string='Planned Revenue per Month'),
-        'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="The email address associated with this team. New emails received will automatically ""create new leads assigned to the team."),
-    }
-
-    def _auto_init(self, cr, context=None):
-        """Installation hook to create aliases for all lead and avoid constraint errors."""
-        return self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(crm_case_section, self)._auto_init,
-            'crm.lead', self._columns['alias_id'], 'name', alias_prefix='Lead+', alias_defaults={}, context=context)
-
-    def _get_stage_common(self, cr, uid, context):
-        ids = self.pool.get('crm.case.stage').search(cr, uid, [('case_default', '=', 1)], context=context)
-        return ids
-
-    _defaults = {
-        'stage_ids': _get_stage_common,
-        'use_leads': True,
-    }
-
-    def create(self, cr, uid, vals, context=None):
-        if context is None:
-            context = {}
-        create_context = dict(context, alias_model_name='crm.lead', alias_parent_model_name=self._name)
-        section_id = super(crm_case_section, self).create(cr, uid, vals, context=create_context)
-        section = self.browse(cr, uid, section_id, context=context)
-        self.pool.get('mail.alias').write(cr, uid, [section.alias_id.id], {'alias_parent_thread_id': section_id, 'alias_defaults': {'section_id': section_id, 'type': 'lead'}}, context=context)
-        return section_id
-
-    def unlink(self, cr, uid, ids, context=None):
-        # Cascade-delete mail aliases as well, as they should not exist without the sales team.
-        mail_alias = self.pool.get('mail.alias')
-        alias_ids = [team.alias_id.id for team in self.browse(cr, uid, ids, context=context) if team.alias_id]
-        res = super(crm_case_section, self).unlink(cr, uid, ids, context=context)
-        mail_alias.unlink(cr, uid, alias_ids, context=context)
-        return res
-
index cc6aba3..8be2d88 100644 (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>
                             <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"/>
             </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>
             <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>
index 6be094c..7f5ae17 100644 (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:
index ef105d3..8acefd5 100644 (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"/>
index 3481e29..995a1dd 100644 (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 -->
index 1cd31cd..d48e66e 100644 (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",
diff --git a/addons/crm/sales_team.py b/addons/crm/sales_team.py
new file mode 100644 (file)
index 0000000..ac62656
--- /dev/null
@@ -0,0 +1,80 @@
+import calendar
+from datetime import date
+from dateutil import relativedelta
+
+from openerp import tools
+from openerp.osv import fields, osv
+
+
+class crm_case_section(osv.Model):
+    _inherit = 'crm.case.section'
+    _inherits = {'mail.alias': 'alias_id'}
+
+    def _get_opportunities_data(self, cr, uid, ids, field_name, arg, context=None):
+        """ Get opportunities-related data for salesteam kanban view
+            monthly_open_leads: number of open lead during the last months
+            monthly_planned_revenue: planned revenu of opportunities during the last months
+        """
+        obj = self.pool.get('crm.lead')
+        res = dict.fromkeys(ids, False)
+        month_begin = date.today().replace(day=1)
+        date_begin = month_begin - relativedelta.relativedelta(months=self._period_number - 1)
+        date_end = month_begin.replace(day=calendar.monthrange(month_begin.year, month_begin.month)[1])
+        lead_pre_domain = [('create_date', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)),
+                ('create_date', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATE_FORMAT)),
+                              ('type', '=', 'lead')]
+        opp_pre_domain = [('date_deadline', '>=', date_begin.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)),
+                      ('date_deadline', '<=', date_end.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)),
+                      ('type', '=', 'opportunity')]
+        for id in ids:
+            res[id] = dict()
+            lead_domain = lead_pre_domain + [('section_id', '=', id)]
+            opp_domain = opp_pre_domain + [('section_id', '=', id)]
+            res[id]['monthly_open_leads'] = self.__get_bar_values(cr, uid, obj, lead_domain, ['create_date'], 'create_date_count', 'create_date', context=context)
+            res[id]['monthly_planned_revenue'] = self.__get_bar_values(cr, uid, obj, opp_domain, ['planned_revenue', 'date_deadline'], 'planned_revenue', 'date_deadline', context=context)
+        return res
+
+    _columns = {
+        'resource_calendar_id': fields.many2one('resource.calendar', "Working Time", help="Used to compute open days"),
+        'stage_ids': fields.many2many('crm.case.stage', 'section_stage_rel', 'section_id', 'stage_id', 'Stages'),
+        'use_leads': fields.boolean('Leads',
+            help="The first contact you get with a potential customer is a lead you qualify before converting it into a real business opportunity. Check this box to manage leads in this sales team."),
+        'monthly_open_leads': fields.function(_get_opportunities_data,
+            type="string", readonly=True, multi='_get_opportunities_data',
+            string='Open Leads per Month'),
+        'monthly_planned_revenue': fields.function(_get_opportunities_data,
+            type="string", readonly=True, multi='_get_opportunities_data',
+            string='Planned Revenue per Month'),
+        'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="The email address associated with this team. New emails received will automatically ""create new leads assigned to the team."),
+    }
+
+    def _auto_init(self, cr, context=None):
+        """Installation hook to create aliases for all lead and avoid constraint errors."""
+        return self.pool.get('mail.alias').migrate_to_alias(cr, self._name, self._table, super(crm_case_section, self)._auto_init,
+            'crm.lead', self._columns['alias_id'], 'name', alias_prefix='Lead+', alias_defaults={}, context=context)
+
+    def _get_stage_common(self, cr, uid, context):
+        ids = self.pool.get('crm.case.stage').search(cr, uid, [('case_default', '=', 1)], context=context)
+        return ids
+
+    _defaults = {
+        'stage_ids': _get_stage_common,
+        'use_leads': True,
+    }
+
+    def create(self, cr, uid, vals, context=None):
+        if context is None:
+            context = {}
+        create_context = dict(context, alias_model_name='crm.lead', alias_parent_model_name=self._name)
+        section_id = super(crm_case_section, self).create(cr, uid, vals, context=create_context)
+        section = self.browse(cr, uid, section_id, context=context)
+        self.pool.get('mail.alias').write(cr, uid, [section.alias_id.id], {'alias_parent_thread_id': section_id, 'alias_defaults': {'section_id': section_id, 'type': 'lead'}}, context=context)
+        return section_id
+
+    def unlink(self, cr, uid, ids, context=None):
+        # Cascade-delete mail aliases as well, as they should not exist without the sales team.
+        mail_alias = self.pool.get('mail.alias')
+        alias_ids = [team.alias_id.id for team in self.browse(cr, uid, ids, context=context) if team.alias_id]
+        res = super(crm_case_section, self).unlink(cr, uid, ids, context=context)
+        mail_alias.unlink(cr, uid, alias_ids, context=context)
+        return res
index 075d782..3b2a8f4 100644 (file)
@@ -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/res_config.py b/addons/sales_team/res_config.py
new file mode 100644 (file)
index 0000000..3081a2e
--- /dev/null
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+
+from openerp.osv import fields, osv
+
+
+class sales_team_configuration(osv.TransientModel):
+    _name = 'sale.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
+            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_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."""),
+    }
diff --git a/addons/sales_team/sales_team_config.py b/addons/sales_team/sales_team_config.py
deleted file mode 100644 (file)
index 1e2a193..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-# -*- 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']
-
-    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_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."""),
-    }
-
-    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
-    }
-
index fe99971..d9002f8 100644 (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>