Skip to content

[MIG][19.0] base_multi_company#1003

Open
Vandan-Pandeji-SerpentCS wants to merge 111 commits into
OCA:19.0from
Vandan-Pandeji-SerpentCS:19.0_MIG_base_multi_company
Open

[MIG][19.0] base_multi_company#1003
Vandan-Pandeji-SerpentCS wants to merge 111 commits into
OCA:19.0from
Vandan-Pandeji-SerpentCS:19.0_MIG_base_multi_company

Conversation

@Vandan-Pandeji-SerpentCS

Copy link
Copy Markdown

No description provided.

lasley and others added 30 commits May 22, 2026 18:51
* 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/
Odoo now checks if the user who creates the transient model is the same that is accessing
its data, so we need to create it with the same user.
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
* Abstract model shouldn't have default for `company_ids`. It will be got by
  default `company_id` value.
* Record rule based on `company_id` makes the evaluation slower. Switch to `company_ids` field.
* Add `@api.depends` to `company_id` computation for proper refresh.
* Fix tests that were not correct but luckily previously suceeded. Now that other code has
  been removed, they have been uncovered.
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: multi-company-12.0/multi-company-12.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-12-0/multi-company-12-0-base_multi_company/
Currently translated at 70.0% (7 of 10 strings)

Translation: multi-company-12.0/multi-company-12.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-12-0/multi-company-12-0-base_multi_company/zh_CN/
ibuioli and others added 28 commits May 22, 2026 18:51
Currently translated at 100.0% (4 of 4 strings)

Translation: multi-company-16.0/multi-company-16.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-base_multi_company/es_AR/
Currently translated at 100.0% (4 of 4 strings)

Translation: multi-company-16.0/multi-company-16.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-base_multi_company/it/
Currently translated at 100.0% (4 of 4 strings)

Translation: multi-company-16.0/multi-company-16.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-16-0/multi-company-16-0-base_multi_company/pt_BR/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: multi-company-17.0/multi-company-17.0-base_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-17-0/multi-company-17-0-base_multi_company/
When searching the company with a domain like [("company_id", "in", [1,
False]) to include records which are shared between companies we won't
get those with no companies at all. That will lead to logical errors in
several workflows.

TT51779

[FIX] base_multi_company: Applying the correct parameters in the search_read() method
Before this commit, when doing a read with a domain such as [the one used by upstream `base.res_partner_rule`][1], the read failed to find records without company.

This is now fixed in the base module, adding tested support for such operators. The only relevant part of the hooks that were provided to workaround the issue is extracted to a new `post_init_hook`. All other hooks are marked as deprecated.

[1]: https://github.com/odoo/odoo/blob/db072461cddced2a8f65a64fb6d2ddf0dd79b38e/odoo/addons/base/security/base_security.xml#L23

@moduon MT-8863 MT-8873
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).
@OCA-git-bot OCA-git-bot added series:19.0 mod:base_multi_company Module base_multi_company labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:base_multi_company Module base_multi_company series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.