[14.0][FIX] product_multi_company: allow editing company_ids on product variant#997
Open
Mert-coderoid wants to merge 1 commit into
Open
Conversation
…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.
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.
The variant's
company_idsis 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 aproduct.productare silently lost.This is observable in setups where end users navigate to
product.product(variant) views instead ofproduct.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
[c1, c2]on a variant → both variant and template end up[c1, c2][c1]while template is[c1, c2]) → template shrinks to[c1](expected)sudo()