[18.0][FIX] brand: Default Company for Correct Brand Validation on wizards#255
Open
[18.0][FIX] brand: Default Company for Correct Brand Validation on wizards#255
Conversation
Contributor
|
Hi @sbejaoui, |
etobella
approved these changes
May 20, 2025
bofiltd
approved these changes
Sep 11, 2025
Contributor
Author
|
@max3903 Can you please merge? |
yvaucher
approved these changes
Sep 17, 2025
Member
|
/ocabot merge patch |
Contributor
|
On my way to merge this fine PR! |
OCA-git-bot
added a commit
that referenced
this pull request
Sep 17, 2025
Contributor
|
@yvaucher your merge command was aborted due to failed check(s), which you can inspect on this commit of 18.0-ocabot-merge-pr-255-by-yvaucher-bump-patch. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
Defaults the `company_id` field on the `product.pricelist.print` wizard to `self.env.company`. This ensures that the `brand_use_level` field (which is related to `company_id.brand_use_level`) is correctly computed upon wizard initialization. Consequently, the brand requirement checks (Python constraints like `_check_brand_requirement`) and UI adjustments (dynamic 'required' or 'invisible' attributes on `brand_id` field via `_get_view`) inherited from the `res.brand.mixin` can function as intended. Without this explicit default, the mixin's logic might not have the correct company context immediately upon wizard load, potentially leading to brand requirement rules not being enforced as expected.
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.
Defaults the
company_idfield on theproduct.pricelist.printwizard toself.env.company.Problem:
The brand requirement validation, which is handled by the
res.brand.mixinand configured via thebrand_use_levelfield onres.company, was not consistently being enforced on the "Print Pricelist" wizard (product.pricelist.print).When a company's
brand_use_levelwas set to 'required', the wizard did not reliably:brand_idfield mandatory in the user interface (UI).brand_idwas not selected, by raising aValidationError.This was primarily due to the
company_idfield on theproduct.pricelist.printwizard instance (inherited fromres.brand.mixin) not having an explicit default value. As a result, the relatedbrand_use_levelfield on the wizard might not compute its value correctly at the moment of wizard creation or when UI attributes were determined. This could lead to the mixin's@api.constrains(like_check_brand_requirement) and its_get_viewmethod (which sets UI properties) not functioning with the intended company context.Solution:
This pull request addresses the issue by explicitly setting a default value for the
company_idfield within our inheritedProductPricelistPrintmodel. Thecompany_idnow defaults to the current user's company:More models might benefit from this change as we encountered inconsistent behaviour on the
sale_brandmodule as well.