Skip to content

[19.0][FIX] base_tier_validation_correction: restrict resource_ref to tier-validated models#34

Open
bosd wants to merge 2 commits into
OCA:19.0from
bosd:19.0-fix-base_tier_validation_correction-resource-ref-domain
Open

[19.0][FIX] base_tier_validation_correction: restrict resource_ref to tier-validated models#34
bosd wants to merge 2 commits into
OCA:19.0from
bosd:19.0-fix-base_tier_validation_correction-resource-ref-domain

Conversation

@bosd
Copy link
Copy Markdown
Contributor

@bosd bosd commented May 13, 2026

Summary

The resource_ref Reference field on tier.correction.item listed every ir.model in its selection callback. Two problems:

  • Performance: the callback ran self.env["ir.model"].search([]) and built ~500 tuples per dropdown render. Noticeable stall on installations with many custom modules.
  • Correctness / UX: the dropdown surfaced models that can't have tier reviews (res.partner, res.country, ...), letting an admin reference a record on a model where no correction is meaningful.

Restrict the selection to the same model set the tier.correction form already uses for its model_id Many2one — tier.definition._get_tier_validation_model_names(). Picker now only offers models that actually support tier validation; the underlying query is bounded to that set.

Test plan

  • Open a tier.correction.item form. The Resource reference dropdown now only includes models that have a tier.definition (e.g. account.move when account_move_tier_validation is installed), not every model in the system.
  • Performance: the ir.model query result set shrinks from ~all models to typically <10. Visible difference on installations with many addons.

…validated models

The `resource_ref` Reference field on `tier.correction.item` listed
every `ir.model` in the database in its selection callback. Two
problems:

- Performance: every time the field's dropdown was rendered, the
  callback ran `self.env["ir.model"].search([])` -- a full read of
  ir.model -- and built ~500 tuples on a stock Odoo install. On large
  databases with many custom modules the picker noticeably stalls.
- Correctness / UX: the dropdown surfaced models that have nothing to
  do with tier validation (res.partner, res.country, ...), letting an
  admin reference a record on a model that cannot have tier reviews
  in the first place.

Restrict the selection to the same model set the `tier.correction`
form already uses for its `model_id` Many2one -- the result of
`tier.definition._get_tier_validation_model_names()`. The picker now
only offers models that actually support tier validation, and the
underlying query is bounded to that set.
@OCA-git-bot
Copy link
Copy Markdown
Contributor

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

@OCA-git-bot OCA-git-bot added series:19.0 mod:base_tier_validation_correction Module base_tier_validation_correction labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:base_tier_validation_correction Module base_tier_validation_correction series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants