Skip to content

[19.0][MIG] base_multi_company#1009

Open
EmilioPascual wants to merge 115 commits into
OCA:19.0from
moduon:19.0-mig-base_multi_company
Open

[19.0][MIG] base_multi_company#1009
EmilioPascual wants to merge 115 commits into
OCA:19.0from
moduon:19.0-mig-base_multi_company

Conversation

@EmilioPascual

Copy link
Copy Markdown

Supersed of #889

I have re-run the migration from the current version 18. The old pull request was quite old and was causing numerous inconsistencies with the latest changes.
I have tried to preserve the commit authorship as far as possible.

@Vandan-Pandeji-SerpentCS, @astirpe, @weinni2000, @Murtaza-OSI, @chienandalu, @yajo please review

@moduon MT-14423

@EmilioPascual EmilioPascual force-pushed the 19.0-mig-base_multi_company branch from 9048459 to d6b759f Compare June 3, 2026 14:44
@OCA-git-bot OCA-git-bot added series:19.0 mod:base_multi_company Module base_multi_company labels Jun 3, 2026
@EmilioPascual EmilioPascual force-pushed the 19.0-mig-base_multi_company branch from d6b759f to 5bb33cf Compare June 5, 2026 07:34
@EmilioPascual

Copy link
Copy Markdown
Author

@OCA/intercompany-maintainers could you review and merge it, please? Thank you

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@BhaveshHeliconia

Copy link
Copy Markdown
Contributor

@EmilioPascual EmilioPascual force-pushed the 19.0-mig-base_multi_company branch from 5bb33cf to 2ce2349 Compare June 9, 2026 10:48
@EmilioPascual

Copy link
Copy Markdown
Author

@EmilioPascual EmilioPascual force-pushed the 19.0-mig-base_multi_company branch from 2ce2349 to 7f22851 Compare June 19, 2026 13:13
@OCA-git-bot OCA-git-bot added the mod:partner_multi_company Module partner_multi_company label Jun 19, 2026
lasley and others added 13 commits June 19, 2026 15:16
* Create new module to provide base multi company logic and mixin
* Add deactivation by company mixin
* Add company_id/ids handling
* Add break after company is found
Squashed commits:
[854cc36] Increase test coverage
[770bd71] Revert hook view create back to model init
[40e803e] Fix apples and oranges
[7a4dfb4] Use registry correctly
[6e9f170] Switch company_id to computed & move company aliased view creation to post init hook
[faa4fc9] Remove active functionality
[fecfb59] Add explicit tests for active and inactive searches
* Revert "Revert hook view create back to model init"

This reverts commit 770bd71.

* [FIX] base_multi_company: Always create the view into a pre_init_hook to avoid error in log
Squashed commits:
[4c17d04] auto_join company_ids
…ch domain on company_id/company_ids (+1 squashed commit)

Squashed commits:
[fe161fe] [ADD] setup.py
- Test if a company is set in inverse method (+1 squashed commit)
Squashed commits:
[d670f30] [FIX] fix init hooks as company_id is not stored anymore
* Add implementation instructions to ReadMe
[FIX] Fix issue based on the computation of company_id for multi_company_abstract models

[FIX] Fix issue based on the computation of company_id for multi_company_abstract models

[FIX] Fix issue based on the computation of company_id for multi_company_abstract models

[FIX] Bad branch version pushed before

[FIX] Bad branch version pushed before

[FIX] manifest

Fix flake

Flake8 on OCA tests
Currently translated at 88.9% (8 of 9 strings)

Translation: multi-company-10.0/multi-company-10.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-10-0/multi-company-10-0-base_multi_company/pt/
OCA-git-bot and others added 19 commits June 19, 2026 15:16
Currently translated at 100.0% (4 of 4 strings)

Translation: multi-company-18.0/multi-company-18.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-base_multi_company/tr/
Prevent AccessError when users with limited company access edit records that have company_ids field.

The issue occurs because:
1. company_ids field values are cached without considering the current user.
2. When a sudo read happens first (e.g., during search), it caches ALL companies.
3. Later non-sudo reads use the same cached value, but the user only has access to some companies.
4. This causes AccessError when checking company permissions.

Solution:
- Add `depends_context=('uid',)` to company_ids field definition.
- This creates separate cache entries for different users (sudo vs non-sudo).
- Each user sees only the companies they have access to.

If fixes the problem reported in the issue OCA#929, using a similar approach as Odoo to solve a similar problem (this is Odoo's original fix PR --> odoo/odoo#217752).
Currently translated at 100.0% (4 of 4 strings)

Translation: multi-company-18.0/multi-company-18.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-base_multi_company/sl/
MT-14423

Co-authored-by: Vandan-SCS <73175574+Vandan-Pandeji-SerpentCS@users.noreply.github.com>
When a record is created or modified via onchange, `record.company_ids[:1]`
may be a virtual (unsaved) record whose `.id` is a `NewId`. Assigning that
to the computed `company_id` field propagates the `NewId` into any
downstream domain — most notably `_compute_same_vat_partner_id` in
`res.partner`, which builds a search domain with
`('company_id', 'in', [False, partner.company_id.id])` and triggers:

    psycopg2.ProgrammingError: can't adapt type 'NewId'

MT-14423 MT-15070 @moduon
@EmilioPascual EmilioPascual force-pushed the 19.0-mig-base_multi_company branch from 7f22851 to 0ad0d7e Compare June 19, 2026 13:17
@OCA-git-bot OCA-git-bot removed the mod:partner_multi_company Module partner_multi_company label Jun 19, 2026

@weinni2000 weinni2000 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rafaelbn

Copy link
Copy Markdown
Member

Please @OCA/intercompany-maintainers could you review and merge it, please? Thank you! ❤️

@EmilioPascual add your self as maintainter, we are maintaining this module 5 years

/ocabot migration base_multi_company

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Sorry @rafaelbn you are not allowed to mark the addon to be migrated.

To do so you must either have push permissions on the repository, or be a declared maintainer of all modified addons.

If you wish to adopt an addon and become it's maintainer, open a pull request to add your GitHub login to the maintainers key of its manifest.

@rafaelbn

Copy link
Copy Markdown
Member

Hello ✋🏼 🤗

Please @gurneyalex @legalsylvain @LoisRForgeFlow , could you merge this one? Is validated, aproved... etc.

Running in prod 😄 ❤️

Others likes #1014 depends on this one

Thank you!
Regards,
Rafa

@tristancatteeuw

Copy link
Copy Markdown

Hello.
Just as a small note, I was testing this module in version 19, and it works fine, but is causing an error in odoo's data cleaning module, as it expects the company_id field to be stored.
ValueError: Cannot convert product.template.company_id to SQL because it is not stored

@chienandalu

Copy link
Copy Markdown
Member

Thanks for the heads up @tristancatteeuw

@EmilioPascual is on holidays right now, so he won't be able to review the issue until he's back

@rafaelbn rafaelbn mentioned this pull request Jul 2, 2026
25 tasks
@rafaelbn

rafaelbn commented Jul 2, 2026

Copy link
Copy Markdown
Member

Hello @tristancatteeuw :

Did you tested in OCA's runboat?

Technical name: data_cleaning
License: Odoo Edición Enterprise v1.0

data_cleaning module is Enterprise so don't affects in this PR

Thank you!
Regards,
Rafael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.