[18.0][FIX] brand: Default Company for Correct Brand Validation on wizards #255
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_id
field on theproduct.pricelist.print
wizard toself.env.company
.Problem:
The brand requirement validation, which is handled by the
res.brand.mixin
and configured via thebrand_use_level
field onres.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:brand_id
field mandatory in the user interface (UI).brand_id
was not selected, by raising aValidationError
.This was primarily due to the
company_id
field on theproduct.pricelist.print
wizard instance (inherited fromres.brand.mixin
) not having an explicit default value. As a result, the relatedbrand_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 inheritedProductPricelistPrint
model. Thecompany_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.