odoo/odoo#189441

Created by Stroobant Paul (stpa)

Blocked

  • Merge method
  • Review
  • CI
label
odoo-dev:16.0-opw-4214192-crm_team_member_company-stpa
head
0f345d8f0285a91b3f05cc973a54bd51508c446c
odoo/odoo
18.0 #189441 missing r+
saas-18.2
saas-18.3
saas-18.4
19.0
master

[FIX] sales_team: align team member company to team company

Steps to reproduce the issue:

(Easier to reproduce client side with CRM installed)

  1. Install crm
  2. Create Second Company
  3. Create New User with Current Company as Default Company and Second Company in Allowed Companies
  4. Create CRM Team belonging to Second Company
  5. Add New User to Members of CRM Team
  6. Receive error:

> [New User] belongs to company [Current Company] and "Sales Team" (crm_team_id: [CRM Team]) belongs to another company.

Explanation:

crm.team.member is created when adding res.users to crm.team.member_ids. Contrary to res.users, a company_check is done when linking crm.team and crm.team.member together. crm.team.member.company_id is related to user_id.company_id and, in the case above, does not match crm.team.company_id, raising an error because of it.

Fix reasoning:

Removing restriction, as we want to avoid other multi-company issues by changing the behaviour.

opw-4214192


@nd-dew note:
Situation recap
image

So it was proposed to modify the field definition, seems to me that removing check_company from the field definition is a legal move, since it is an ORM level constraint (doesn't change db schema).

However looking at the tests it seems like this is desired limitation.

Note that #171079 introduced checking for allowed companies, but the default company still takes priority.