From a69076851a1db8eaf29c29e762694dc03678e60a Mon Sep 17 00:00:00 2001
From: Denis Ledoux <dle@odoo.com>
Date: Thu, 11 Dec 2014 13:21:18 +0100
Subject: [PATCH] [FIX] crm: do not assign a salesteam to a lead if not in
 multi sales team env

on_change_user was used to assign the first team  in which the user is a member to the lead
When the user does not use the multi sales team, it therefore set a default sales team, but invisible to the user.

Stages displayed in the kanban view are the lead sales team stages. In a non sales team env, only stages with no stages are displayed for new leads
If you added a new stage, in the kanban view, the stage is not assigned to a team
---
 addons/crm/crm_lead.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py
index 992e4f365eab..d142b4aa4037 100644
--- a/addons/crm/crm_lead.py
+++ b/addons/crm/crm_lead.py
@@ -330,7 +330,7 @@ class crm_lead(format_address, osv.osv):
         """ When changing the user, also set a section_id or restrict section id
             to the ones user_id is member of. """
         section_id = self._get_default_section_id(cr, uid, user_id=user_id, context=context) or False
-        if user_id and not section_id:
+        if user_id and self.pool['res.users'].has_group(cr, uid, 'base.group_multi_salesteams') and not section_id:
             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]
-- 
GitLab