Skip to content

[19.0][MIG] base_multi_company - #1009

Merged
OCA-git-bot merged 115 commits into
OCA:19.0from
moduon:19.0-mig-base_multi_company
Jul 21, 2026
Merged

OCA-git-bot merged 115 commits into
OCA:19.0from
moduon:19.0-mig-base_multi_company

Conversation

@EmilioPascual

Copy link
Copy Markdown
Contributor

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
Contributor 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
Contributor Author

@EmilioPascual EmilioPascual mentioned this pull request Jun 19, 2026
1 task done
@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 7 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/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
6 of 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

@LoisRForgeFlow LoisRForgeFlow 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.

The migration looks good, however there are a few additional commits. In this one this new tests dragged my attention, see my comment below:

uninstall_hook(self.env, rule_ref)

self.assertFalse(rule.active)
self.assertIn("company_ids", rule.domain_force)

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.

After applying uninstall hook company_ids remains in the domain? does it make sense?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

After applying uninstall hook company_ids remains in the domain? does it make sense?

Good catch, but this is intentional. The uninstall_hook is deprecated and its purpose is to deactivate the rule (active = False), not to restore the original domain. Since the rule is inactive, the domain_force content is irrelevant for security enforcement.

Keeping company_ids in the domain_force is a safety measure: if the module is reinstalled later, the post_init_hook will re-activate the rule with the correct domain. If we cleared the domain_force on uninstall, the rule would be re-activated with an empty/incorrect domain upon reinstall.

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.

@EmilioPascual Thanks for the explanation. This would probably need some more discussion, I think is not the cleanest way to resolve it. However, I also think it is not the most valuable discussion as uninstallation of this module will be really infrequent, not to mention re-installation. So let's move forward as is to focus on more important details :)

@LoisRForgeFlow

Copy link
Copy Markdown
Contributor

/ocabot migration base_multi_company

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Jul 6, 2026
@EmilioPascual

Copy link
Copy Markdown
Contributor Author

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

Thanks for the report. This is a known limitation of the module's design: company_id is intentionally a non-stored computed field because its value is context-dependent (it changes based on the current user's companies). The actual stored field is company_ids (Many2many).

Modules that expect company_id to be stored in the database (like data_cleaning) will need to handle this. However, this behavior is not new in the 19.0 migration — it has been the same since the module was created. If you need company_id as a stored field in a specific model, you can add store=True with the appropriate compute/depends in your own module's inheritance.

@LoisRForgeFlow

Copy link
Copy Markdown
Contributor

/ocabot merge nobump

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 19.0-ocabot-merge-pr-1009-by-LoisRForgeFlow-bump-nobump, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 311b6b1 into OCA:19.0 Jul 21, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at c110ce7. Thanks a lot for contributing to OCA. ❤️

@yajo
yajo deleted the 19.0-mig-base_multi_company branch August 20, 2026 11:27
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.