brand icon indicating copy to clipboard operation
brand copied to clipboard

[18.0][FIX] brand: Default Company for Correct Brand Validation on wizards

Open bosd opened this issue 7 months ago • 5 comments

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:

  1. Make the brand_id field mandatory in the user interface (UI).
  2. Prevent the user from proceeding if a brand_id was not selected, by raising a ValidationError.

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.

bosd avatar May 16 '25 15:05 bosd

Hi @sbejaoui, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar May 16 '25 15:05 OCA-git-bot

@max3903 Can you please merge?

bosd avatar Sep 11 '25 12:09 bosd

/ocabot merge patch

yvaucher avatar Sep 17 '25 14:09 yvaucher

On my way to merge this fine PR! Prepared branch 18.0-ocabot-merge-pr-255-by-yvaucher-bump-patch, awaiting test results.

OCA-git-bot avatar Sep 17 '25 14:09 OCA-git-bot

@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.

OCA-git-bot avatar Sep 17 '25 14:09 OCA-git-bot