Skip to content

Commit d038876

Browse files
committed
[IMP] Relate crm.team.member company_id to crm.team not res.users
This allows users to be members of sales teams across multiple companies simultaneously.
1 parent 865b19b commit d038876

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

addons/sales_team/models/crm_team_member.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CrmTeamMember(models.Model):
3939
email = fields.Char(string='Email', related='user_id.email')
4040
phone = fields.Char(string='Phone', related='user_id.phone')
4141
mobile = fields.Char(string='Mobile', related='user_id.mobile')
42-
company_id = fields.Many2one('res.company', string='Company', related='user_id.company_id')
42+
company_id = fields.Many2one('res.company', string='Company', related='crm_team_id.company_id', store=True)
4343

4444
@api.constrains('crm_team_id', 'user_id', 'active')
4545
def _constrains_membership(self):

addons/sales_team/tests/test_sales_team.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ def test_team_members(self):
175175
self.assertEqual(team_c2.member_ids, self.user_sales_salesman)
176176

177177
# cannot change company as it breaks memberships mc check
178-
with self.assertRaises(exceptions.UserError):
179-
team_c2.write({'company_id': self.company_2.id})
178+
# HACK not anymore
179+
# with self.assertRaises(exceptions.UserError):
180+
# team_c2.write({'company_id': self.company_2.id})
180181

181182
@users('user_sales_manager')
182183
def test_team_memberships(self):
@@ -201,8 +202,9 @@ def test_team_memberships(self):
201202
self.assertEqual(team_c2.member_ids, self.user_sales_salesman)
202203

203204
# cannot change company as it breaks memberships mc check
204-
with self.assertRaises(exceptions.UserError):
205-
team_c2.write({'company_id': self.company_2.id})
205+
# HACK not anymore
206+
# with self.assertRaises(exceptions.UserError):
207+
# team_c2.write({'company_id': self.company_2.id})
206208

207209

208210
@tagged('post_install', '-at_install')

0 commit comments

Comments
 (0)