fix(spp_registry): drop non-writeable @constrains('age') load warning#357
Open
reichie020212 wants to merge 1 commit into
Open
fix(spp_registry): drop non-writeable @constrains('age') load warning#357reichie020212 wants to merge 1 commit into
reichie020212 wants to merge 1 commit 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 72.45% 72.25% -0.20%
==========================================
Files 1022 1032 +10
Lines 60834 61106 +272
==========================================
+ Hits 44080 44155 +75
- Misses 16754 16951 +197
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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; the stale constraint docstring is updated to record the removal.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. A follow-up could add@api.constrains("birthdate")rejecting future dates (writeable field → no warning, and covers ORM/import).Base
Branched from
7973befto match the commit currently deployed on 4Ps preprod; targets19.0.7973befis an ancestor of19.0, so the diff is just this one change.