Skip to content

[MIG][19.0] partner_multi_company#901

Open
Vandan-Pandeji-SerpentCS wants to merge 63 commits into
OCA:19.0from
Vandan-Pandeji-SerpentCS:19.0_MIG_partner_multi_company
Open

[MIG][19.0] partner_multi_company#901
Vandan-Pandeji-SerpentCS wants to merge 63 commits into
OCA:19.0from
Vandan-Pandeji-SerpentCS:19.0_MIG_partner_multi_company

Conversation

@Vandan-Pandeji-SerpentCS

Copy link
Copy Markdown

Depending Module: #889

@Vandan-Pandeji-SerpentCS Vandan-Pandeji-SerpentCS force-pushed the 19.0_MIG_partner_multi_company branch from 84a5fc3 to bd9ceef Compare November 4, 2025 13:56
@Vandan-Pandeji-SerpentCS Vandan-Pandeji-SerpentCS changed the title [MIG][19.0]partner_multi_company [MIG][19.0] partner_multi_company Nov 5, 2025
@isturiz

isturiz commented Dec 16, 2025

Copy link
Copy Markdown

@astirpe astirpe mentioned this pull request Mar 14, 2026
3 tasks
@astirpe

astirpe commented Mar 15, 2026

Copy link
Copy Markdown
Member

@Vandan-Pandeji-SerpentCS I opened a PR to your branch: Vandan-Pandeji-SerpentCS#1
Could you have a look?

@EmilioPascual

Copy link
Copy Markdown

Hi @Vandan-Pandeji-SerpentCS! Could you handle the requests and rebase for run runboat? Thank you

@astirpe I don't think he'll reply, it's been two months since you wrote to him. Perhaps, you could add the commit history to your PR and supersed this one if it still doesn't respond . What do you think?

@Vandan-OSI

Copy link
Copy Markdown

Hi @Vandan-Pandeji-SerpentCS! Could you handle the requests and rebase for run runboat? Thank you

@astirpe I don't think he'll reply, it's been two months since you wrote to him. Perhaps, you could add the commit history to your PR and supersed this one if it still doesn't respond . What do you think?

@EmilioPascual I'll take a look at this week & update you.

@OCA-git-bot OCA-git-bot added series:19.0 mod:partner_multi_company Module partner_multi_company labels May 14, 2026
oihane and others added 20 commits May 14, 2026 14:33
This fix prevents errors when there are other tests that create partners
and base_suspend_security is still not ready. There can be still problems
if these partners are not created with SUPERUSER.
* Bump versions
* Rename manifest
* Rename openerp to odoo
* Implement base_multi_company

Add depends

Swap dependencies

Add base_suspend_security depend back & server-tools repo

Fix tests

Add test for partner._commercial_fields

Why not both?!
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

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

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

Translation: multi-company-12.0/multi-company-12.0-partner_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-12-0/multi-company-12-0-partner_multi_company/
rven and others added 21 commits May 14, 2026 14:33
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: multi-company-17.0/multi-company-17.0-partner_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-17-0/multi-company-17-0-partner_multi_company/
Currently translated at 100.0% (6 of 6 strings)

Translation: multi-company-17.0/multi-company-17.0-partner_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-17-0/multi-company-17-0-partner_multi_company/it/
In the partner_multi_company module, the display_name field had to be
redefined as store and index because the module installation removed
those field properties. As of v17 the field is no longer store so it is
not necessary to redefine it as storable. In addition, this redefinition
causes errors when printing reports because the field is not calculated
when accessing and therefore only shows the data stored in the database,
which is not updated until one of the fields of the dependency changes.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: multi-company-17.0/multi-company-17.0-partner_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-17-0/multi-company-17-0-partner_multi_company/
When a new company is created with user_ids, the update of the users in done only on cache level so the user's partner's company is not aligned.
Propagate user default company
Write on users triggers a write on the partners that validates the partners' companies, but partners' companies haven't been aligned yet so it raises the partner's companies constraint.
Align the companies in the partners first, so that writing on users (and therefore on partners) will satisfy the constraint.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: multi-company-18.0/multi-company-18.0-partner_multi_company
Translate-URL: https://translation.odoo-community.org/projects/multi-company-18-0/multi-company-18-0-partner_multi_company/
* [IMP][19.0] partner_multi_company: fix hook duplicate key error

* [DON'T MERGE] test-requirements.txt

* [DON'T MERGE] test-requirements.txt
@Vandan-Pandeji-SerpentCS Vandan-Pandeji-SerpentCS force-pushed the 19.0_MIG_partner_multi_company branch from 2db1266 to e57c364 Compare May 14, 2026 09:04
@Vandan-Pandeji-SerpentCS

Copy link
Copy Markdown
Author

Hi @Vandan-Pandeji-SerpentCS! Could you handle the requests and rebase for run runboat? Thank you

@astirpe I don't think he'll reply, it's been two months since you wrote to him. Perhaps, you could add the commit history to your PR and supersed this one if it still doesn't respond . What do you think?

Done. Please check now.

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

Good job @Vandan-Pandeji-SerpentCS

Functional and code review.

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

Great work, thanks for the contribution @Vandan-Pandeji-SerpentCS . I have reviewed the module and performed the following functional tests in a multi-company environment:

Test 1: OK - Global partner without companies assigned is visible from both companies.
Test 2: OK - Partner restricted to one company is only visible for users with access to that company.
Test 3: OK - Partner assigned to two companies is visible and usable from both companies.
Test 4: OK - When creating a partner, the current company is correctly proposed by default.
Test 5: OK - Removing all companies from a partner makes it available globally again.
Test 6: OK - It is not possible to remove from a user’s partner a company that is still assigned to the related user.
Test 7: OK - Adding a new allowed company to a user correctly updates the related partner companies.
Test 8: OK - Changing the user’s main company keeps the related partner company access consistent.
Test 9: OK - Child contacts correctly follow the commercial partner company configuration.
Test 10: OK - The known roadmap limitation about different companies on child contacts has been reviewed and behaves consistently with the current implementation.
Test 11: OK - After uninstalling the module, the standard partner company rule is restored.
Test 12: OK - Existing partners with a company assigned before installation are correctly migrated to the new multi-company field.

All tested scenarios worked as expected, so this PR looks good to me. Thank you again for the work.

Image

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

Code and functional review LGTM!

@mikecolangelo

Copy link
Copy Markdown

Hi @Vandan-Pandeji-SerpentCS, thanks for the migration! While running this port in a real multi-company deployment (Odoo 19, alongside the rest of the multi-company stack) we hit three issues you may want to fold into this PR. Fixes for all three, with regression tests, are on our fork and you're welcome to cherry-pick them:

  1. Test suite never actually runs on 19.0test_partner_multi_company.py still uses the pre-19 groups_id field in res.users.create(), so setUpClass errors out and every test in the class is skipped. Fix: rename to group_ids. (commit)

  2. post_init_hook scopes base.res_partner_rule by the active company selection instead of the user's real membership — the patched rule uses the bare company_ids eval-context variable (self.env.companies, i.e. whatever is checked in the company switcher right now). A company's own contact typically has no linked users, so it doesn't qualify for the partner_share = False branch and falls through to the company check: any user genuinely assigned to a company still gets an AccessError reading that company's own contact the moment their switcher has fewer companies active than they belong to (e.g. an administrator creating a user from Settings). Fix: use user.company_ids.ids in both patched rules. (commit)

  3. _check_company_id rejects a transient mid-create state — creating a user whose partner already has a company (an existing partner promoted to user, or any module putting a default on res.partner.company_id, e.g. partner_company_default) with several companies in one create() call crashes with "The partner must have at least all the companies associated with the user": base res.users.create() syncs the partner's company_id mid-create, its inverse narrows company_ids, and the constraint fires before this module's own create override aligns the partner with all the user's companies. Fix: skip the constraint while the user create is in flight; the alignment write re-triggers it on the final state. (commit)

Related: OCA/partner-contact#2401 fixes the partner_company_default side of the same composition problem.

Happy to open a PR against your branch instead if that's easier — just say the word.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.