[19.0][ADD] product_company_default: scope new products to the active company#1026
Draft
mikecolangelo wants to merge 1 commit into
Draft
[19.0][ADD] product_company_default: scope new products to the active company#1026mikecolangelo wants to merge 1 commit into
mikecolangelo wants to merge 1 commit into
Conversation
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.
|
@mikecolangelo Your proposed module is already exist in this repo. |
Author
|
Oh, i got it, thanks and sorry @AungKoKoLin1997 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New module:
product_company_defaultproduct_multi_companyleaves new products global by default (emptycompany_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 ofpartner_company_default(OCA/partner-contact).Implementation notes:
company_idsis set directly increate()instead of putting a default oncompany_id:company_idis a computed/inverse field onmulti.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).Command.set([])only produces a deliberately global product for users holdingbase.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.