mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-26 23:12:05 +02:00
19.0 vanilla
This commit is contained in:
parent
a1137a1456
commit
e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions
|
|
@ -1,47 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, api
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ReportProjectTaskUser(models.Model):
|
||||
_inherit = "report.project.task.user"
|
||||
|
||||
hours_planned = fields.Float('Planned Hours', readonly=True)
|
||||
hours_effective = fields.Float('Effective Hours', readonly=True)
|
||||
remaining_hours = fields.Float('Remaining Hours', readonly=True)
|
||||
progress = fields.Float('Progress', group_operator='avg', readonly=True)
|
||||
overtime = fields.Float(readonly=True)
|
||||
allocated_hours = fields.Float('Allocated Time', readonly=True, groups="hr_timesheet.group_hr_timesheet_user")
|
||||
effective_hours = fields.Float('Time Spent', readonly=True, groups="hr_timesheet.group_hr_timesheet_user")
|
||||
remaining_hours = fields.Float('Time Remaining', readonly=True, groups="hr_timesheet.group_hr_timesheet_user")
|
||||
remaining_hours_percentage = fields.Float('Time Remaining Percentage', readonly=True, groups="hr_timesheet.group_hr_timesheet_user")
|
||||
progress = fields.Float('Progress', aggregator='avg', readonly=True, groups="hr_timesheet.group_hr_timesheet_user")
|
||||
overtime = fields.Float(readonly=True, groups="hr_timesheet.group_hr_timesheet_user")
|
||||
|
||||
def _select(self):
|
||||
select_to_append = """,
|
||||
(t.effective_hours * 100) / NULLIF(t.planned_hours, 0) as progress,
|
||||
t.effective_hours as hours_effective,
|
||||
t.planned_hours - t.effective_hours - t.subtask_effective_hours as remaining_hours,
|
||||
NULLIF(t.planned_hours, 0) as hours_planned,
|
||||
t.overtime as overtime
|
||||
return super()._select() + """,
|
||||
CASE WHEN COALESCE(t.allocated_hours, 0) = 0 THEN NULL ELSE t.effective_hours * 100 / t.allocated_hours END as progress,
|
||||
NULLIF(t.effective_hours, 0) as effective_hours,
|
||||
CASE WHEN COALESCE(t.allocated_hours, 0) = 0 THEN NULL ELSE t.allocated_hours - t.effective_hours END as remaining_hours,
|
||||
CASE WHEN t.allocated_hours > 0 THEN t.remaining_hours / t.allocated_hours ELSE 0 END as remaining_hours_percentage,
|
||||
NULLIF(t.allocated_hours, 0) as allocated_hours,
|
||||
NULLIF(t.overtime, 0) as overtime
|
||||
"""
|
||||
return super(ReportProjectTaskUser, self)._select() + select_to_append
|
||||
|
||||
def _group_by(self):
|
||||
group_by_append = """,
|
||||
return super()._group_by() + """,
|
||||
t.effective_hours,
|
||||
t.subtask_effective_hours,
|
||||
t.planned_hours,
|
||||
t.allocated_hours,
|
||||
t.overtime
|
||||
"""
|
||||
return super(ReportProjectTaskUser, self)._group_by() + group_by_append
|
||||
|
||||
@api.model
|
||||
def _get_view_cache_key(self, view_id=None, view_type='form', **options):
|
||||
"""The override of _get_view changing the time field labels according to the company timesheet encoding UOM
|
||||
makes the view cache dependent on the company timesheet encoding uom"""
|
||||
key = super()._get_view_cache_key(view_id, view_type, **options)
|
||||
return key + (self.env.company.timesheet_encode_uom_id,)
|
||||
|
||||
@api.model
|
||||
def _get_view(self, view_id=None, view_type='form', **options):
|
||||
arch, view = super()._get_view(view_id, view_type, **options)
|
||||
if view_type in ['pivot', 'graph'] and self.env.company.timesheet_encode_uom_id == self.env.ref('uom.product_uom_day'):
|
||||
arch = self.env['account.analytic.line']._apply_time_label(arch, related_model=self._name)
|
||||
return arch, view
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue