[19.0][FIX] payroll: explicit default for credit_note boolean field #315
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.60) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.60 · 233 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.326
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.060
Real PR Conversation Timeline
1 comments
"Review active on #315"
general
weight: 0.35
nimarosa
Problem
hr.payslip.credit_notehas no explicit Python-level default. Upthrough Odoo 12.0, the core ORM's
_create()had a safety net thatforce-set any missing boolean field to
Falsebefore the INSERT(explicit comment: "avoid NULL in database"). That safety net was
removed in Odoo core in August 2019
(odoo/odoo@9920f20e4, part of the ORM cache-rewrite in
odoo/odoo#35659, landed in saas-12.5) and has not existed in any
version since.
Since this field is never passed explicitly by most payslip creation
call sites (API-driven creation, scripted creation, imports, etc.),
every such payslip now gets
credit_note = NULLat the databaselevel instead of
False.This silently breaks
sum_rule()inbase_browsable.py, which sumsa payslip's contribution using raw SQL:
case when hp.credit_note = False then pl.total else -pl.total end
Under SQL three-valued logic,
NULL = Falseevaluates toNULL(not
TRUE), so theCASEfalls through toELSEand subtractsthat payslip's amount instead of adding it - silently corrupting any
cumulative figure built with
sum_rule()(e.g. year-to-date totals)for every payslip that has a NULL credit_note.
Fix
Add
default=Falseto the field declaration. This is the correctplace to own this - current Odoo ORM guidance is that boolean fields
should declare their own default rather than relying on implicit
insert-time behavior, and relying on that removed ORM behavior was
never documented or guaranteed in the first place.
Note for existing data
This fix only affects rows created after it's applied. Existing
NULLrows on an installation need a one-time backfill, e.g.:UPDATE hr_payslip SET credit_note = False WHERE credit_note IS NULL;
(Left out of this PR since it's an operational/data step for each
installation, not something the module should do automatically.)