[19.0][ADD] payroll_work_entry: compute worked days from work entries - #284
[19.0][ADD] payroll_work_entry: compute worked days from work entries#284neoand wants to merge 1 commit into
Conversation
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
695ba19 to
6f11008
Compare
|
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 |
|
In Odoo Community, |
| """ | ||
| self.ensure_one() | ||
| res = [] | ||
| remaining = self.env["hr.version"] |
There was a problem hiding this comment.
remaining = self.env["hr.contract"].browse() # Empty recordset of the correct model
|
Cierro este PR por decisión interna de pausar contribuciones a OCA a partir del 15-ago-2026. El código queda archivado en mi fork privado ( Agradezco a @nimarosa por la aprobación, a @CristianoMafraJunior por la primera revisión (trailer de IA) y por la observación técnica sobre el recordset inicial en — Anderson |
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.