task_with_hours
On timesheet lines, the task dropdown shows each task's remaining allocated hours while you search, then hides them once you pick. That is the task_with_hours widget from hr_timesheet.
| Technical name | task_with_hours |
|---|---|
| Field types | many2one (project.task) |
| Views | form, list |
| Module | hr_timesheet (Timesheets app) |
| Used in core | 3 occurrences in hr_timesheet, on task_id of timesheet lines |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0, Odoo 16.0 |
| No-code setup | No. Applied by the Timesheets views; reuse needs XML |
| Alternatives | many2one, many2one_avatar_user, timesheet_uom |
What the task picker widget does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
no_create | boolean | Inherited from many2one. Removes all creation routes. Note that creation is already blocked whenever the context has no default_project_id. |
no_quick_create | boolean | Inherited from many2one. Removes the inline create entry only. |
no_create_edit | boolean | Inherited from many2one. Removes the create-and-edit dialog entry only. |
no_open | boolean | Inherited from many2one. Prevents navigating to the task from the field in readonly. |
search_threshold | number | Inherited from many2one, new in 19. Minimum typed characters before the dropdown searches, useful on databases with thousands of tasks.(since Odoo 19.0) |
placeholder_field | field name | Inherited from many2one, new in 19. Char field on the record supplying a dynamic placeholder.(since Odoo 19.0) |
The creation gate wins over creation options. The component ANDs its project check into canCreate, canCreateEdit and canQuickCreate after the normal options are computed. Adding no_create tightens behavior as usual, but nothing you set in XML can enable creation while the context lacks default_project_id; the gate is code, not configuration.
Working examples
The non-breaking space contract
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Framework props migration only on the development branch; behavior identical. See below. |
| Odoo 19.0 | Verified | Compositional rewrite on the new Many2One building block; behavior verified identical to 18. |
| Odoo 18.0 | Verified | Same file as 17, byte for byte. No XML changes needed. |
| Odoo 17.0 | Verified | Consolidated single component subclassing Many2OneField. |
| Odoo 16.0 | Verified | Behavior present twice: OWL component plus a legacy widget for the old grid view. |
Upgrade note. XML using this widget carries over unchanged from 16 through 19. JavaScript patches do not: 16 to 18 subclass Many2OneField with overridable getters, 19 is a composition around Many2One, so patches must be rewritten at the 19 boundary. If you patched the old grid-view widget in 16, that code has no successor at all.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| No remaining hours shown in the dropdown | The tasks have no allocated_hours set, or timesheets are disabled on them; the server only appends the suffix when both conditions hold. Set allocated time on the tasks and enable timesheets on the project. |
| Cannot create a task from the dropdown | The line has no project yet, so default_project_id is missing from the context and the widget disables all creation. Pick the project first; creation unlocks and the new task lands in it. |
| Hours show as days like (1.5 days remaining) | The company's timesheet encoding unit is days, and the server formats accordingly. Expected; change the encoding unit in Timesheets settings if you want hours. |
| The selected task chip shows the remaining hours too | A custom display name override replaced the non-breaking space with a normal space, breaking the widget's trim. Keep the \u00A0 separator in any _compute_display_name override. |
| A minus sign appears in the suffix | The task's logged time exceeds its allocation; remaining hours are negative. That is the overrun warning working; rebalance the allocation or the logged time. |
| JavaScript patch stopped working after upgrading to 19 | The widget changed from a Many2OneField subclass to a composition around Many2One. Rewrite the patch against the 19 component; getter overrides no longer exist. |
Task picker widget vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
task_with_hours | Task selection on timesheet lines with hour budgets | Remaining-time suffix in the dropdown only, creation gated on the project |
| many2one | Task references outside timesheet context | No hours suffix, normal creation rules |
| many2one_avatar_user | Assignee fields next to the task | Avatar chip for users, no budget information |
| timesheet_uom | The duration column on the same line | Formats the hours value itself, dispatching per company encoding unit |
Frequently asked questions
What does the task_with_hours widget do?+
Why do some tasks show remaining hours and others do not?+
How is the remaining time formatted?+
Why is there no Create option in my task dropdown?+
Does task_with_hours support the usual many2one options?+
Can I use task_with_hours outside the Timesheets app?+
Does the widget change in Odoo 20?+
Timesheets that defend the budget while hours are logged
We configure task allocations, remaining-hours visibility and approval flows so project budgets surface inside daily timesheet entry, not in month-end reports. If your fixed-price projects leak hours quietly, the fix starts in this dropdown.
Make my timesheets budget-aware