Skip to content

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

Open
neoand wants to merge 1 commit into
OCA:19.0from
neoand:19.0-add-payroll_work_entry
Open

[19.0][ADD] payroll_work_entry: compute worked days from work entries#284
neoand wants to merge 1 commit into
OCA:19.0from
neoand:19.0-add-payroll_work_entry

Conversation

@neoand

@neoand neoand commented Aug 8, 2026

Copy link
Copy Markdown

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.

@OCA-git-bot OCA-git-bot added series:19.0 mod:payroll_work_entry Module payroll_work_entry labels Aug 8, 2026

@CristianoMafraJunior CristianoMafraJunior left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
neoand force-pushed the 19.0-add-payroll_work_entry branch from 695ba19 to 6f11008 Compare August 11, 2026 10:30
@neoand

neoand commented Aug 11, 2026

Copy link
Copy Markdown
Author

Thanks for pointing me to the policy — that one's on me, and it's fixed now.

The commit was using Co-authored-by: for the AI tool, which the policy rules out. I've amended it
to use the Assisted-by: trailer instead and added the disclosure to the description.

Happy to answer anything about the implementation directly — I'd much rather work through review
comments than regenerate the patch. Thanks for taking the time to look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:payroll_work_entry Module payroll_work_entry series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants