| 1 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 2 |
|
| 3 |
from odoo import fields, models |
| 4 |
|
| 5 |
|
| 6 |
class ReportProjectTaskUser(models.Model): |
| 7 |
_inherit = "report.project.task.user" |
| 8 |
|
| 9 |
allocated_hours = fields.Float('Allocated Time', readonly=True, groups="hr_timesheet.group_hr_timesheet_user") |
| 10 |
effective_hours = fields.Float('Time Spent', readonly=True, groups="hr_timesheet.group_hr_timesheet_user") |
| 11 |
remaining_hours = fields.Float('Time Remaining', readonly=True, groups="hr_timesheet.group_hr_timesheet_user") |
| 12 |
remaining_hours_percentage = fields.Float('Time Remaining Percentage', readonly=True, groups="hr_timesheet.group_hr_timesheet_user") |
| 13 |
progress = fields.Float('Progress', aggregator='avg', readonly=True, groups="hr_timesheet.group_hr_timesheet_user") |
| 14 |
overtime = fields.Float(readonly=True, groups="hr_timesheet.group_hr_timesheet_user") |
| 15 |
|
| 16 |
def _select(self): |
| 17 |
return super()._select() + """, |
| 18 |
CASE WHEN COALESCE(t.allocated_hours, 0) = 0 THEN NULL ELSE t.effective_hours * 100 / t.allocated_hours END as progress, |
| 19 |
NULLIF(t.effective_hours, 0) as effective_hours, |
| 20 |
CASE WHEN COALESCE(t.allocated_hours, 0) = 0 THEN NULL ELSE t.allocated_hours - t.effective_hours END as remaining_hours, |
| 21 |
CASE WHEN t.allocated_hours > 0 THEN t.remaining_hours / t.allocated_hours ELSE 0 END as remaining_hours_percentage, |
| 22 |
NULLIF(t.allocated_hours, 0) as allocated_hours, |
| 23 |
NULLIF(t.overtime, 0) as overtime |
| 24 |
""" |
| 25 |
|
| 26 |
def _group_by(self): |
| 27 |
return super()._group_by() + """, |
| 28 |
t.effective_hours, |
| 29 |
t.allocated_hours, |
| 30 |
t.overtime |
| 31 |
""" |