[18.0][FIX] brand: Default Company for Correct Brand Validation on wizards
Defaults the company_id field on the product.pricelist.print wizard to self.env.company.
Problem:
The brand requirement validation, which is handled by the res.brand.mixin and configured via the brand_use_level field on res.company, was not consistently being enforced on the "Print Pricelist" wizard (product.pricelist.print).
When a company's brand_use_level was set to 'required', the wizard did not reliably:
- Make the
brand_idfield mandatory in the user interface (UI). - Prevent the user from proceeding if a
brand_idwas not selected, by raising aValidationError.
This was primarily due to the company_id field on the product.pricelist.print wizard instance (inherited from res.brand.mixin) not having an explicit default value. As a result, the related brand_use_level field 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_view method (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_id field within our inherited ProductPricelistPrint model. The company_id now defaults to the current user's company:
More models might benefit from this change as we encountered inconsistent behaviour on the sale_brand module as well.
Hi @sbejaoui, some modules you are maintaining are being modified, check this out!
@max3903 Can you please merge?
/ocabot merge patch
On my way to merge this fine PR! Prepared branch 18.0-ocabot-merge-pr-255-by-yvaucher-bump-patch, awaiting test results.
@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.