Skip to content

[19.0][MIG]base_multi_company#889

Open
Vandan-Pandeji-SerpentCS wants to merge 108 commits into
OCA:19.0from
Vandan-Pandeji-SerpentCS:19.0-MIG-base_multi_company
Open

[19.0][MIG]base_multi_company#889
Vandan-Pandeji-SerpentCS wants to merge 108 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 October 14, 2025 12:38
* 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/

@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

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

@JayVora-SerpentCS

Copy link
Copy Markdown

@OCA-git-bot remind the maintainers to merge this Pr pls. cc @weinni2000

@astirpe

astirpe commented Mar 15, 2026

Copy link
Copy Markdown
Member

@Vandan-Pandeji-SerpentCS I made a PR to your branch, could you check? Vandan-Pandeji-SerpentCS#2

@EmilioPascual

Copy link
Copy Markdown

@Vandan-Pandeji-SerpentCS could you add the missing commits since the PR was opened? Thank you.

@moduon MT-14423

@EmilioPascual

EmilioPascual commented May 20, 2026

Copy link
Copy Markdown

@Vandan-Pandeji-SerpentCS could you please check the PR that @astirpe commented you and apply the missing commits? Those comments are quite old. Otherwise, we’ll have to superseed the PR. Thank you.

@OCA-git-bot OCA-git-bot added series:19.0 mod:base_multi_company Module base_multi_company labels May 21, 2026
@Vandan-Pandeji-SerpentCS

Copy link
Copy Markdown
Author

@Vandan-Pandeji-SerpentCS could you please check the PR that @astirpe commented you and apply the missing commits? Those comments are quite old. Otherwise, we’ll have to superseed the PR. Thank you.

@EmilioPascual Done. Could you please check now?

@EmilioPascual

Copy link
Copy Markdown

@Vandan-Pandeji-SerpentCS could you please check the PR that @astirpe commented you and apply the missing commits? Those comments are quite old. Otherwise, we’ll have to superseed the PR. Thank you.

@EmilioPascual Done. Could you please check now?

There are still some commits missing from 18.0 such as 1de1ecc, 35e45c0 or bb502d6

@Vandan-Pandeji-SerpentCS

Copy link
Copy Markdown
Author

@Vandan-Pandeji-SerpentCS could you please check the PR that @astirpe commented you and apply the missing commits? Those comments are quite old. Otherwise, we’ll have to superseed the PR. Thank you.

@EmilioPascual Done. Could you please check now?

There are still some commits missing from 18.0 such as 1de1ecc, 35e45c0 or bb502d6

Okay, I'll add it.

@Vandan-Pandeji-SerpentCS Vandan-Pandeji-SerpentCS force-pushed the 19.0-MIG-base_multi_company branch 4 times, most recently from b61759a to 7d357a5 Compare May 25, 2026 06:31
@Vandan-Pandeji-SerpentCS Vandan-Pandeji-SerpentCS force-pushed the 19.0-MIG-base_multi_company branch from 7d357a5 to 0fd2a47 Compare May 25, 2026 06:37
@Vandan-Pandeji-SerpentCS

Copy link
Copy Markdown
Author

@EmilioPascual
Unit test cases are failing because the pull request at #942 has failed checks. Could you please guide me?

Comment on lines +41 to +44
if company_id in sudo_record.company_ids.ids:
record.company_id = company_id
else:
record.company_id = sudo_record.company_ids[:1].id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Testing this module in a complete instance we're having some issues with this compute in certain cases when a NewId enters from an onchange or something like that...

It causes this error:

  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/res_partner.py", line 477, in _compute_same_vat_partner_id
    partner.same_vat_partner_id = should_check_vat and not partner.parent_id and Partner.search(domain, limit=1)
                                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

This code is more resilient as we tested locally:

Suggested change
if company_id in sudo_record.company_ids.ids:
record.company_id = company_id
else:
record.company_id = sudo_record.company_ids[:1].id
company_ids = sudo_record.company_ids._origin.ids or sudo_record.company_ids.ids
if company_id in company_ids:
record.company_id = company_id
else:
company = sudo_record.company_ids[:1]
if company and isinstance(company.id, models.NewId):
record.company_id = company._origin.id or False
else:
record.company_id = company.id

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@chienandalu could you review #1009?
I think I've fixed it

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.