[FIX] crm, website_crm_partner_assign: recompute saleteam automatically

Add a constrains on user_id field to avoid to recompute manually the team_id.

Eg: action_foward didn't call the onchange manually, so the saleteam not updated.
This commit is contained in:
Jeremy Kersten
2017-06-08 15:41:07 +02:00
parent 3741603495
commit fdc8749888
2 changed files with 1 additions and 2 deletions
+1
View File
@@ -249,6 +249,7 @@ class Lead(models.Model):
team_id = self.env['crm.team']._get_default_team_id(user_id=user_id)
return {'team_id': team_id}
@api.constrains('user_id')
@api.onchange('user_id')
def _onchange_user_id(self):
""" When changing the user, also set a team_id or restrict team id to the ones user_id is member of. """
@@ -47,8 +47,6 @@ class CrmLead(models.Model):
for salesman_id, leads_ids in salesmans_leads.items():
leads = self.browse(leads_ids)
leads.write({'user_id': salesman_id})
for lead in leads:
lead._onchange_user_id()
@api.multi
def action_assign_partner(self):