[14.0][FIX] partner_multi_company: sync user-partner companies on install - #996
Open
Mert-coderoid wants to merge 1 commit into
Open
[14.0][FIX] partner_multi_company: sync user-partner companies on install#996Mert-coderoid wants to merge 1 commit into
Mert-coderoid wants to merge 1 commit into
Conversation
Contributor
|
Hi @renda-dev, @PicchiSeba, @aleuffre, |
Mert-coderoid
force-pushed
the
14.0-fix-partner-multi-company-user-sync
branch
from
April 30, 2026 14:08
5ccae43 to
37f5fa4
Compare
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
force-pushed
the
14.0-fix-partner-multi-company-user-sync
branch
from
April 30, 2026 14:30
37f5fa4 to
cc1eb18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
post_init_hookonly copies the legacypartner.company_id(Many2one) into the newcompany_ids(Many2many) field, ignoringres.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 withAccessErrorwhen_loginreadsuser.tz(related field on partner). The unhandledAccessErrorsurfaces as a 500 page since the navbar template's fallback also goes through the partner record.Reproduction (clean 14.0)
company_id=A,company_ids=[A, B]partner_multi_company: post_init_hook setsU.partner_id.company_ids = {A}Fix
Add an extra
INSERTinpost_init_hookthat adds, for every user with apartner_id, every company the user is allowed in. The same SQL is run as a14.0.1.2.0post-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.pyoverride, included for regression safety).Closes #995
Closes #438