[FIX] crm: default sales team computation

Delegate the whole default sales team computation to the _get_default_team_id
of sales team to ease the overriding and understanding. Otherwise part of the
behavior is implemented in crm, part in sales team, leading to a difficult
overriding.

Order

 - team the user is member of
 - team in context
 - Direct Sales
This commit is contained in:
Thibault Delavallée
2015-12-14 17:09:35 +01:00
parent f6dd8994d6
commit 14008d055b
2 changed files with 5 additions and 9 deletions
+1 -5
View File
@@ -294,11 +294,7 @@ class crm_lead(format_address, osv.osv):
team = self.pool['crm.team'].browse(cr, uid, context['team_id'], context=context)
if user_id in team.member_ids.ids:
return {}
team_ids = self.pool.get('crm.team').search(
cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], limit=1, context=context)
team_id = team_ids and team_ids[0] or False
if not team_id:
team_id = self.pool['crm.team']._get_default_team_id(cr, uid, context=context, user_id=user_id)
team_id = self.pool['crm.team']._get_default_team_id(cr, uid, context=context, user_id=user_id)
return {'value': {'team_id': team_id}}
def stage_find(self, cr, uid, cases, team_id, domain=None, order='sequence', context=None):
+4 -4
View File
@@ -16,10 +16,10 @@ class crm_team(osv.Model):
context = {}
if user_id is None:
user_id = uid
team_id = context.get('default_team_id')
if not team_id:
team_ids = self.search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', 'in', user_id)], limit=1, context=context)
team_id = team_ids[0] if team_ids else False
team_ids = self.search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', 'in', user_id)], limit=1, context=context)
team_id = team_ids[0] if team_ids else False
if not team_id and context.get('default_team_id'):
team_id = context['default_team_id']
if not team_id:
team_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'sales_team.team_sales_department')
return team_id