Skip to content

[14.0][FIX] partner_multi_company: sync user-partner companies on install - #996

Open
Mert-coderoid wants to merge 1 commit into
OCA:14.0from
Mert-coderoid:14.0-fix-partner-multi-company-user-sync
Open

[14.0][FIX] partner_multi_company: sync user-partner companies on install#996
Mert-coderoid wants to merge 1 commit into
OCA:14.0from
Mert-coderoid:14.0-fix-partner-multi-company-user-sync

Conversation

@Mert-coderoid

Copy link
Copy Markdown

The post_init_hook only copies the legacy partner.company_id (Many2one) into the new company_ids (Many2many) field, ignoring res.users.company_ids.

For users allowed in more than one company, this leaves their own partner record visible in only the company that happened to be in the legacy partner.company_id. Logging in under any other allowed company fails with AccessError when _login reads user.tz (related field on partner). The unhandled AccessError surfaces as a 500 page since the navbar template's fallback also goes through the partner record.

Reproduction (clean 14.0)

  • Two companies: A, B
  • User U: company_id=A, company_ids=[A, B]
  • Install partner_multi_company: post_init_hook sets U.partner_id.company_ids = {A}
  • Log in as U, switch to company B → 500

Fix

Add an extra INSERT in post_init_hook that adds, for every user with a partner_id, every company the user is allowed in. The same SQL is run as a 14.0.1.2.0 post-migration so existing installations get the backfill on upgrade.

Two new tests cover create-time and write-time sync (handled by the existing res_users.py override, included for regression safety).

Closes #995
Closes #438

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @renda-dev, @PicchiSeba, @aleuffre,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:14.0 mod:partner_multi_company Module partner_multi_company labels Apr 30, 2026
@Mert-coderoid
Mert-coderoid force-pushed the 14.0-fix-partner-multi-company-user-sync branch from 5ccae43 to 37f5fa4 Compare April 30, 2026 14:08
The post_init_hook only copied the legacy partner.company_id (Many2one)
into the new company_ids (Many2many) field, ignoring res.users.company_ids.

For users allowed in more than one company, this leaves their own partner
record visible in only the company that happened to be in the legacy
partner.company_id. Logging in under any other allowed company fails with
AccessError when _login reads user.tz (related field on partner). The
unhandled AccessError surfaces as a 500 page since the navbar template's
fallback also goes through the partner record.

Add an extra INSERT in post_init_hook that adds, for every user with a
partner_id, every company the user is allowed in. Same SQL is run as a
14.0.1.2.0 post-migration so existing installations get the backfill on
upgrade.

Closes OCA#995
Closes OCA#438
@Mert-coderoid
Mert-coderoid force-pushed the 14.0-fix-partner-multi-company-user-sync branch from 37f5fa4 to cc1eb18 Compare April 30, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:partner_multi_company Module partner_multi_company series:14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants