[19.0][ADD] payroll_work_entry: compute worked days from work entries - #284
Open
neoand wants to merge 1 commit into
Open
[19.0][ADD] payroll_work_entry: compute worked days from work entries#284neoand wants to merge 1 commit into
neoand wants to merge 1 commit into
Conversation
CristianoMafraJunior
suggested changes
Aug 10, 2026
payroll derives a payslip's worked days from the resource calendar: what the employee should have worked. Where an installation records hr.work.entry — attendances, overtime, absences — that data describes what actually was, so this module makes the payslip use it. Without it, a payroll for a workforce that clocks in silently ignores its own attendance records: overtime is never paid and absences never deducted, because the calendar says every day was a full one. Lines are grouped by the payroll code of the work entry type. 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. Only validated entries count — a conflict is Odoo saying the record is not trustworthy. Contracts with no work entry in the period keep the calendar computation, so installing this changes nothing for them. 0 failed, 0 errors of 7 tests on odoo:19.0 Community without demo data. Assisted-by: Claude Opus 4.8
neoand
force-pushed
the
19.0-add-payroll_work_entry
branch
from
August 11, 2026 10:30
695ba19 to
6f11008
Compare
Author
|
Thanks for pointing me to the policy — that one's on me, and it's fixed now. The commit was using Happy to answer anything about the implementation directly — I'd much rather work through review |
nimarosa
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New module: build a payslip's worked days from
hr.work.entry.Why
payrollderives worked days from the resource calendar — what the employee should have worked (hr_payslip.py,_compute_worked_days, withcompute_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_entryis Community in 19.0, andhr.work.entryis already adapted tohr.version, so the bridge is small.What it does
worked_days.OVERTIMEhours_per_day, so a 12-hour shift counts as one day rather than one and a halfContracts 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
validatedentries 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 testsonodoo:19.0Community, 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 bareresource.calendarwith no attendance lines makes every entry fall outside calendar and unvalidatable — the tests copy the company calendar; and writingstate = 'validated'directly leaves the record in conflict, so they go throughaction_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.