-
-
Notifications
You must be signed in to change notification settings - Fork 194
[18.0][FIX] brand: Default Company for Correct Brand Validation on wizards #255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Conversation
|
Hi @sbejaoui, |
|
@max3903 Can you please merge? |
|
/ocabot merge patch |
|
On my way to merge this fine PR! |
|
@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.
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.