[18.0][FIX] payroll_contract_advantages: bound validation, data integrity and precision #287
All Vouch review confidence checks passed
Residual risk 0.43 = Change Risk (0.73) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.73 · 360 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.352
Shallow Review Depth
shallow_review_depth
0.344
Sensitive Paths
sensitive_paths
0.073
Real PR Conversation Timeline
1 comments
"Review active on #287"
general
weight: 0.35
nimarosa
What's broken today
hr.contract.advantage._check_bound_limits()treats0.0as a real bound instead of"no limit on that side". Any
hr.contract.advantage.templateleft with the default(unset)
lower_bound/upper_boundtherefore rejects every non-zero amount,making the advantage type unusable until an admin discovers they must also fill in
bounds that have no
requiredflag or hint suggesting so.payroll_contract_advantages/models/hr_payslip.pybuilds a{code: amount}dict fromcontract.advantages_ids, so a duplicate line silently overwrites one amount with theother with no warning, and the resulting payslip total is wrong without any error
being raised.
hr.contract.advantage.templaterecords from sharing the samecode. That code is the key salary rules use to read the value (advantages.<CODE>),so a duplicate code makes two different advantages collide in the same computation.
hr.contract.advantage.contract_idis notrequiredand has noondelete, sodeleting a contract leaves orphaned
hr.contract.advantagerows withcontract_id = NULLinstead of being cleaned up.hr.contract.advantage.templateallows saving adefault_valueoutside its ownlower_bound/upper_bound, and allowslower_bound > upper_bound— analready-inconsistent template that only surfaces the problem later, when someone tries
to use it.
amount(on the advantage line) andlower_bound/upper_bound/default_value(on the template) use plain
Floatwith no digits precision, unlike the rest of thepayroll engine which consistently uses the
Payroll(2 decimals) precision formonetary-like amounts.
What this PR changes
hr_contract_advantage.py-
_check_bound_limits(): a bound of0.0is now treated as "not set", matching thecommon Odoo convention, instead of blocking every non-zero amount.
-
contract_id: nowrequired=True, ondelete="cascade".-
advantage_template_id: nowrequired=True.-
amount: now usesdigits="Payroll".- New SQL constraint
contract_template_unique: one template per contract.hr_contract_advantage_template.py- New SQL constraint
code_unique.- New
_check_bounds_consistency(): rejectslower_bound > upper_boundand adefault_valueoutside the template's own bounds (same "0.0= no limit"convention).
-
lower_bound/upper_bound/default_value: now usedigits="Payroll".(
test_onchange_advantage_template_sets_default_amount) whose fixture value becameinconsistent with the new bound-consistency check.
cc @nimarosa @pedrobaeza