← Back to Pull requests

[19.0][ADD] payroll_work_entry: compute worked days from work entries #284

Closed
unknown closed this pull request without merging on Aug 25, 2026 01:48 UTC
View on GitHub
unknown unknown commented on Aug 08, 2026 17:10 UTC
Author

New module: build a payslip's worked days from hr.work.entry.

Why

payroll derives worked days from the resource calendar — what the employee should have worked (hr_payslip.py, _compute_worked_days, with compute_leaves=False). Where an installation records work entries, that data describes what actually was worked: attendances, overtime, absences.

For a workforce that clocks in, the difference is not cosmetic. The payslip silently ignores the attendance records the system already has: overtime is never paid and absences are never deducted, because the calendar says every day was a full one.

hr_work_entry is Community in 19.0, and hr.work.entry is already adapted to hr.version, so the bridge is small.

What it does

  • Takes the validated work entries falling inside the payslip period

  • Groups them by the payroll code of their work entry type — one worked-days line per code, so rules can address them as worked_days.OVERTIME

  • Hours come from the entries; days are derived from the contract calendar's hours_per_day, so a 12-hour shift counts as one day rather than one and a half

  • A type with no payroll code is skipped: a rule has no way to reference it
  • Contracts with no work entry in the period fall back to payroll's calendar computation, so installing this module changes nothing for them.

    On states

    Only validated entries count. Draft, cancelled and conflicting ones are deliberately excluded: a conflict is Odoo telling you the record is not trustworthy, and paying it would hide the problem instead of surfacing it.

    Worth knowing when adopting this: Odoo validates one work entry per employee and day. A second entry on a date that already has a validated one stays in conflict, so overtime recorded on the same day as an attendance needs a work entry model that accounts for it or it will never reach the payslip. That is upstream behaviour, not something this module introduces, but it is the first thing people hit.

    Testing

    0 failed, 0 errors of 7 tests on odoo:19.0 Community, on a database without demo data.

    Coverage: hours taken from the entries rather than the calendar, one line per type, a rule reading the recorded hours, draft/cancelled entries excluded, entries outside the period ignored, days following hours_per_day, and the fallback to the calendar when there are no entries.

    Fixtures are built in setUpClass. Two details that cost me time and are baked into them: a bare resource.calendar with no attendance lines makes every entry fall outside calendar and unvalidatable — the tests copy the company calendar; and writing state = 'validated' directly leaves the record in conflict, so they go through action_validate().

    ---

    Assisted-by: Claude Opus 4.8

    Disclosed per the OCA Generative AI / LLM Policy.
    Developed and verified under my direction and review; I take responsibility for the contribution.

    Diff: 374 lines (+280 / -94) across 4 files Reviewer: nimarosa Review duration: 23558m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.66) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.66 · 374 lines diff across 4 files
    0.66
    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%
    57%
    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.355
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.066
    Real PR Conversation Timeline
    1 comments
    "Review active on #284"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% 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: 66% (HIGH) · Higher = larger blast radius
    66%
    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: 58.0% · Lower = rushed or shallow review
    58.0%
    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: 27.7% · Safe to merge
    27.7%
    Repository