Skip to content

[14.0][FIX] product_multi_company: allow editing company_ids on product variant#997

Open
Mert-coderoid wants to merge 1 commit into
OCA:14.0from
Mert-coderoid:14.0-product-multi-company-variant-inverse
Open

[14.0][FIX] product_multi_company: allow editing company_ids on product variant#997
Mert-coderoid wants to merge 1 commit into
OCA:14.0from
Mert-coderoid:14.0-product-multi-company-variant-inverse

Conversation

@Mert-coderoid

Copy link
Copy Markdown

The variant's company_ids is a stored compute field derived from the template. Without an inverse, any write (e.g. from the variant form) gets overwritten by the next compute pass, so attempts to assign companies on a product.product are silently lost.

This is observable in setups where end users navigate to product.product (variant) views instead of product.template — the field renders, the user picks companies, hits Save, and the value disappears on reload.

Fix

Add an inverse that propagates the change to the template, using sudo() so users with variant write access can still trigger the propagation (the template-level rule may be stricter).

The propagation naturally syncs all variants of the same template, which matches the module's existing model (companies live on the template; variants follow).

Tested

  • Write [c1, c2] on a variant → both variant and template end up [c1, c2]
  • Subset write ([c1] while template is [c1, c2]) → template shrinks to [c1] (expected)
  • Empty write → both variant and template empty
  • Re-write same value → no loop (~8ms)
  • Multi-record write across variants of different templates → each template updated correctly
  • Write by a user with no template-write rule → succeeds via sudo()

…iant

The variant's company_ids is a stored compute field that derives from the
template. Without an inverse, writing it (e.g. from the variant form) gets
overwritten by the next compute pass, so any UI attempt to assign companies
on the variant is silently lost.

Add an inverse that propagates the change to the template, using sudo() so
users with variant write access (but not template write access on the
related rules) can still assign companies. The propagation naturally syncs
all variants of the same template, matching the module's "company on the
template" model.

Useful for setups where end users open product.product (variant) views
directly instead of product.template.
@OCA-git-bot OCA-git-bot added series:14.0 mod:product_multi_company Module product_multi_company labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:product_multi_company Module product_multi_company series:14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants