Skip to content

[19.0][ADD] base_field_length_constraint - #1320

Open
AungKoKoLin1997 wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-add-base_field_length_constraint
Open

[19.0][ADD] base_field_length_constraint#1320
AungKoKoLin1997 wants to merge 1 commit into
OCA:19.0from
qrtl:19.0-add-base_field_length_constraint

Conversation

@AungKoKoLin1997

@AungKoKoLin1997 AungKoKoLin1997 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This module enforces a maximum length on char, text and html fields,
defined as configuration data rather than in code.

A rule declares the limit of one field of one model, counted in characters or
in the bytes of a given encoding, and optionally restricted to a company or to
the records matching a domain. An over-long value is refused when the record
is saved, or only reported if the rule is set to warn.

@qrtl QT7079

@OCA-git-bot OCA-git-bot added series:19.0 mod:base_field_length_constraint Module base_field_length_constraint labels Aug 3, 2026
@AungKoKoLin1997
AungKoKoLin1997 force-pushed the 19.0-add-base_field_length_constraint branch 3 times, most recently from f53e7b4 to f262b3a Compare August 4, 2026 03:55
@AungKoKoLin1997
AungKoKoLin1997 marked this pull request as ready for review August 4, 2026 05:15
@AungKoKoLin1997
AungKoKoLin1997 force-pushed the 19.0-add-base_field_length_constraint branch 2 times, most recently from ef0dbec to 150c423 Compare August 12, 2026 02:26
@AungKoKoLin1997

Copy link
Copy Markdown
Contributor Author

I added mute_logger on the test that exercises the violation cap: that path logs a warning by design, and the warning showing up in the Odoo log makes CI fail. Muting the module's logger keeps the run clean.

@kanda999

Copy link
Copy Markdown

Conditional rules can be bypassed when only a field used by the condition is updated — validation is skipped if the constrained field itself is not present in field_names.

For example:

  1. Create a rule on res.partner.ref with max = 5 and condition [('is_company', '=', True)].
  2. Save ref = "123456" on a non-company partner. This correctly succeeds because the rule does not apply yet.
  3. Change only is_company to True. The form write sends only {'is_company': True}.
  4. At this point, field_names == {'is_company'} and does not contain ref, so the error rule is silently skipped even though the record now matches the condition and ref violates the rule.

@AungKoKoLin1997
AungKoKoLin1997 force-pushed the 19.0-add-base_field_length_constraint branch from 150c423 to 8bca74c Compare August 19, 2026 06:35
@AungKoKoLin1997

Copy link
Copy Markdown
Contributor Author

Conditional rules can be bypassed when only a field used by the condition is updated — validation is skipped if the constrained field itself is not present in field_names.

@kanda999 I updated the code to retrigger for the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:base_field_length_constraint Module base_field_length_constraint series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants