← Back to Pull requests

[19.0][FIX] payroll: explicit default for credit_note boolean field #315

Closed
unknown closed this pull request without merging on Oct 05, 2026 22:50 UTC
View on GitHub
unknown unknown commented on Oct 05, 2026 15:11 UTC
Author

Problem

hr.payslip.credit_note has no explicit Python-level default. Up
through Odoo 12.0, the core ORM's _create() had a safety net that
force-set any missing boolean field to False before 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 = NULL at the database
level instead of False.

This silently breaks sum_rule() in base_browsable.py, which sums
a 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 = False evaluates to NULL
(not TRUE), so the CASE falls through to ELSE and subtracts
that 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=False to the field declaration. This is the correct
place 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
NULL rows 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.)

Diff: 233 lines (+174 / -59) across 2 files Reviewer: nimarosa Review duration: 459m
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
0.60
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 60.3% (MEDIUM) · Higher = larger blast radius
60.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 23.8% · Safe to merge
23.8%
Repository