Skip to content

[19.0][ADD] product_company_default: scope new products to the active company#1026

Draft
mikecolangelo wants to merge 1 commit into
OCA:19.0from
CanariasConectada:19.0-add-product_company_default
Draft

[19.0][ADD] product_company_default: scope new products to the active company#1026
mikecolangelo wants to merge 1 commit into
OCA:19.0from
CanariasConectada:19.0-add-product_company_default

Conversation

@mikecolangelo

Copy link
Copy Markdown

New module: product_company_default

product_multi_company leaves new products global by default (empty company_ids = visible to every company). For a strict per-company setup that is the wrong default: a merchant creating a product should get it scoped to their own company without having to touch (or even see) the multi-company field. This is the product-side counterpart of partner_company_default (OCA/partner-contact).

Implementation notes:

  • company_ids is set directly in create() instead of putting a default on company_id: company_id is a computed/inverse field on multi.company.abstract, and letting its inverse run during create triggers an early write that the company record rule rejects (see also [19.0][FIX] partner_company_default: don't stomp an explicit company assignment partner-contact#2401 for the same pitfall on the partner side).
  • An explicit company choice is respected — interpreted from the actual commands, not plain truthiness, so an emptying command such as Command.set([]) only produces a deliberately global product for users holding base.group_multi_company; for everyone else (the field is hidden from them; such a value is only reachable through RPC/imports) the default scoping applies.

Status

Draft: depends on product_multi_company, whose 19.0 migration is not merged yet (#911-family). Will be marked ready once the dependency lands. 4 tests, pre-commit green; validated live in a multi-company deployment sandbox together with the rest of the isolation stack.

product_multi_company leaves new products global by default (empty
company_ids = visible to every company). For a strict per-company setup
that is the wrong default: a merchant creating a product should get it
scoped to their own company without having to touch (or even see) the
multi-company field.

Set company_ids directly in create() instead of defaulting company_id:
company_id is a computed/inverse field on multi.company.abstract, and
letting its inverse run during create triggers an early write that the
company record rule rejects.

An explicit company choice is respected -- interpreted from the actual
commands, not plain truthiness, so an emptying command such as
Command.set([]) only produces a deliberately global product for users
holding base.group_multi_company; for everyone else (the field is hidden
from them; such a value is only reachable through RPC/imports) the
default scoping applies.
@OCA-git-bot OCA-git-bot added series:19.0 mod:product_company_default Module product_company_default labels Jul 2, 2026
@AungKoKoLin1997

Copy link
Copy Markdown

@mikecolangelo Your proposed module is already exist in this repo.
https://github.com/OCA/product-attribute/tree/19.0/product_company_default

@mikecolangelo

Copy link
Copy Markdown
Author

Oh, i got it, thanks and sorry @AungKoKoLin1997

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

Labels

mod:product_company_default Module product_company_default series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants