-
- Downloads
[FIX] hr_timesheet: calculate effective_hours on all users' hours
Reproduction:
1. Install Timesheet, and Project, check the timesheet box in the
setting of Project
2. Go to Setting->manage users, set access right for Marc Demo, Project
as “User”, Timesheets as “See own timesheets”, and Helpdesk as “User”
3. Go to Project, create a task and assign it to Marc Demo, go to the
timesheet tab, set Initially Planned Hours as 20 hours, click save
4. Open an incognito page and log in as Marc Demo, go to this new task->
timesheet, edit, log 5 hours, save. Hour spent is now 5
5. Switch back to Mitchell Admin, refresh the task page, edit, log 3
hours, save. Hour spent is now 8.
6. Switch to the incognito page of Marc Demo, edit, log 2 hours and save
Hour spent is now 7, which doesn’t consider the hours logged by Mitchell
The right result should be 10 hours.
7. Switch back as Mitchell Demo, the spent hours are also wrong
Reason: The cause is that effective_hours is a stored computed field.
When Marc Demo logs hours after Mithcell Admin, the hours from Mitchell
do not show for Marc Demo. Marc Demo cannot get the hours from other
users because he can only see his own timesheet. Thus the computation is
wrong and because it’s a stored computed field, it won’t change even
after switching back to Mitchell Admin
Fix: Use read_group to get the grouped by value of the amount spent on
the task. This makes sure that the value of Hours spent is correctly
computed after saving. It also allows the onchange to take the change
made by the user into account before saving.
opw-2909444
closes odoo/odoo#97241
Signed-off-by:
Laurent Stukkens (ltu) <ltu@odoo.com>
Please register or sign in to comment