[17.0][FIX] hr_holidays_natural_period: avoid request unit recomputations #287
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 353 lines diff across 4 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.351
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #287"
general
weight: 0.35
edescalona
@BinhexTeam
Problem
In
hr_holidays_natural_period17.0, the natural-period durationcalculation temporarily changes
hr.leave.type.request_unitthroughORM writes.
For natural-day leave types,
_get_duration()temporarily changes:natural_daytodaynatural_day_half_daytohalf_dayand restores the original value after the duration has been computed.
A similar temporary change is performed in
hr.employee._get_consumed_leaves().Since
hr.leave.typeis a shared configuration record andrequest_unitparticipates in leave duration dependencies, these ORMwrites can trigger unnecessary recomputations for leaves using the same
leave type.
With a significant number of leaves, this can cause an important
performance degradation. Concurrent computations can additionally
contend on the same
hr.leave.typerecords.Upstream reference
The same performance problem was addressed in the 18.0 branch of this
module.
The relevant upstream fix is:
98ad08d42f632a572068cdfedc4d407ffeee6019[FIX] hr_holidays_natural_period: Performance problem on number_of_dayshttps://github.com/OCA/hr-holidays/pull/238The 18.0 implementation avoids using ORM writes for these temporary
request_unitchanges and usesenv.cache.update_raw()instead, thuspreventing the temporary value changes from triggering the normal ORM
recomputation mechanism.
The 18.0 implementation also avoids modifying the leave type again when
it is already being processed through
mod_holidays_status_ids.Proposed solution for 17.0
Backport the same approach to the 17.0 implementation while preserving
the 17.0 API and behavior.
The change:
hr.leave.type.request_unitwithenv.cache.update_raw();hr.leave._get_duration()andhr.employee._get_consumed_leaves();request_unitvalue after the calculation;_get_duration()when the leavetype is already being handled through
mod_holidays_status_ids,following the guard used by the 18.0 implementation.
This is intentionally a minimal backport. The 18.0 implementation uses
the newer
_get_durations()batch API, while 17.0 still uses thesingleton
_get_duration()API, so the complete 18.0 implementationcannot be applied directly to 17.0.
Validation
The existing
hr_holidays_natural_period17.0 test suite passes afterthe change:
The existing natural-day and natural-half-day scenarios continue to
produce the expected duration results.
SQL-level verification was also performed to ensure that the temporary
duration calculations no longer generate the corresponding
UPDATE hr_leave_typeoperations for changing and restoringrequest_unit.