fix(spp_registry): drop non-writeable @constrains('age') load warning - #357
Open
reichie020212 wants to merge 5 commits into
Open
fix(spp_registry): drop non-writeable @constrains('age') load warning#357reichie020212 wants to merge 5 commits into
reichie020212 wants to merge 5 commits into
Conversation
`age` is a non-stored compute derived from `birthdate`, so
`@api.constrains("age")` never fired — Odoo only runs constrains on
stored writes — and it emitted this warning at every registry load:
method res.partner._check_age_is_integer: @constrains parameter
'age' is not writeable
The check was also redundant: `age` is fully derived from `birthdate`
and can never carry user-supplied input, so `_check_age_is_integer` is
removed as dead code. The `age` field, its `_compute_calc_age` compute,
and `compute_age_from_dates` are unchanged, so every computed `age`
value behaves exactly as before. Existing creation regression tests are
kept; the stale constraint docstring is updated to record the removal.
Signed-off-by: Red <redickbutay02@gmail.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
reichie020212
force-pushed
the
fix/registry-age-constrains-not-writeable
branch
from
July 24, 2026 11:43
3e73f77 to
a8c9bc9
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 19.0 #357 +/- ##
==========================================
- Coverage 74.28% 72.26% -2.03%
==========================================
Files 372 1011 +639
Lines 25385 60736 +35351
==========================================
+ Hits 18857 43890 +25033
- Misses 6528 16846 +10318
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
…trains-not-writeable
…moved age constraint
The 'Age must be a valid integer.' msgid no longer exists in code; remove
it from es.po, fr.po and the .pot. Rename TestCheckAgeIsInteger (named
after the removed method) to TestAgeCreationBehavior and correct the
docstring: a plain @api.constrains('birthdate') would not fire on a
create that omits birthdate, so only the stored-compute variant is the
re-introduction these tests guard against.
gonzalesedwin1123
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
At every registry load,
spp_registrylogs:Infra reports this warning as deployment-log noise on the 4Ps preprod stack.
Root cause
res.partner.age(spp_registry/models/individual.py) is a non-stored computed field:@api.constrains("age")on a non-stored compute is exactly what Odoo warns about — constrains hooks only run on stored writes, so_check_age_is_integernever actually fired. It was also redundant:ageis fully derived frombirthdate(str(years), or"No Birthdate!"), so it can never carry user-supplied input.Fix
Remove the dead
@api.constrains("age")/_check_age_is_integerguard. Theagefield, its_compute_calc_agecompute, andcompute_age_from_datesare unchanged, so every computedagevalue is produced exactly as before — behavior-preserving. The existing creation regression tests are kept.Cleanup shipped with the removal:
"Age must be a valid integer."message dropped fromes.po,fr.po, andspp_registry.pot.TestCheckAgeIsInteger(named after the removed method) renamed toTestAgeCreationBehavior, and its docstring corrected: a plain@api.constrains("birthdate")would not fire on a create that omitsbirthdate, so only the stored-compute variant is the naive re-introduction the tests guard against.spp_registry→19.0.2.1.4+readme/HISTORY.mdentry (README regen via CI's pinned generator).Note (pre-existing, out of scope)
agecan still be a negative string (e.g."-3") whenbirthdateis set to a future date via ORM/import/API — only the_birthdate_onchangeguard (UI form) blocks future dates. The removed constraint never caught this either (non-stored compute), so this PR doesn't change that behavior. Follow-up tracked in #362: add@api.constrains("birthdate")rejecting future dates (writeable field → no warning, and covers ORM/import).Base
Originally branched from
7973bef(the commit deployed on 4Ps preprod) so the fix could be verified against that stack.origin/19.0has since been merged into the branch so the19.0.2.1.4version bump sits on top of19.0.2.1.3without manifest/HISTORY conflicts. The code diff vs19.0remains: the constraint removal, the i18n/test cleanup, and the version bump.