Skip to content

fix(spp_registry): drop non-writeable @constrains('age') load warning#357

Open
reichie020212 wants to merge 1 commit into
19.0from
fix/registry-age-constrains-not-writeable
Open

fix(spp_registry): drop non-writeable @constrains('age') load warning#357
reichie020212 wants to merge 1 commit into
19.0from
fix/registry-age-constrains-not-writeable

Conversation

@reichie020212

Copy link
Copy Markdown
Member

Problem

At every registry load, spp_registry logs:

WARNING ... odoo.models: method res.partner._check_age_is_integer: @constrains parameter 'age' is not writeable

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:

age = fields.Char(compute="_compute_calc_age", size=50, readonly=True)

@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_integer never actually fired. It was also redundant: age is fully derived from birthdate (str(years), or "No Birthdate!"), so it can never carry user-supplied input.

Fix

Remove the dead @api.constrains("age") / _check_age_is_integer guard. The age field, its _compute_calc_age compute, and compute_age_from_dates are unchanged, so every computed age value 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)

age can still be a negative string (e.g. "-3") when birthdate is set to a future date via ORM/import/API — only the _birthdate_onchange guard (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 7973bef to match the commit currently deployed on 4Ps preprod; targets 19.0. 7973bef is an ancestor of 19.0, so the diff is just this one change.

`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>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@reichie020212
reichie020212 force-pushed the fix/registry-age-constrains-not-writeable branch from 3e73f77 to a8c9bc9 Compare July 24, 2026 11:43
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.25%. Comparing base (7973bef) to head (a8c9bc9).
⚠️ Report is 120 commits behind head on 19.0.

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
spp_analytics 93.13% <ø> (ø)
spp_api_v2 79.97% <ø> (+0.10%) ⬆️
spp_api_v2_change_request 66.41% <ø> (+0.45%) ⬆️
spp_api_v2_cycles 70.65% <ø> (+0.48%) ⬆️
spp_api_v2_data 77.43% <ø> (+12.13%) ⬆️
spp_api_v2_entitlements 69.96% <ø> (+0.23%) ⬆️
spp_api_v2_gis 71.52% <ø> (-15.32%) ⬇️
spp_api_v2_products 65.66% <ø> (+0.63%) ⬆️
spp_api_v2_programs 92.03% <ø> (?)
spp_api_v2_service_points 70.54% <ø> (+0.40%) ⬆️
spp_api_v2_simulation 71.12% <ø> (ø)
spp_api_v2_vocabulary 57.26% <ø> (ø)
spp_approval 50.29% <ø> (ø)
spp_area 80.07% <ø> (ø)
spp_area_hdx 81.43% <ø> (ø)
spp_audit 72.04% <ø> (ø)
spp_base_common 90.26% <ø> (ø)
spp_programs 65.27% <ø> (ø)
spp_registry 87.12% <ø> (+0.28%) ⬆️
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_registry/models/individual.py 89.58% <ø> (+2.45%) ⬆️

... and 52 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant