Files
odoo_source/addons/project/report/project_report.py
T
Mitali Patel 8a585c0739 [IMP] sale_(project), hr_timesheet: improve task analysis report
Purpose of the commit is to improve the task analysis report
of the project app.

So in this commit, done the below changes:
- removed the # of tasks measure
- added the following measures: Rating Value (/5), Working Hours to Assign, Working Hours to Close
- removed the # from the labels of the following measures: Days to Deadline, Working Days to Assign,Working Days to Close
- renamed 'task title' into 'task'
- added a search on tag_ids and sale_order_id
- added the following filters:
   -My Projects + My Team's Projects
   -My Tasks + My Team's Tasks (rename 'Unassigned' into 'Unassigned Tasks')
   -Starred
   -Tasks Late + Tasks in Overtime
- added the following group bys: task, customer, kanban state, assignment date, creation date, deadline, last stage update

closes odoo/odoo#72587

Taskid: 2508645
Signed-off-by: LTU-Odoo <IT-Ideas@users.noreply.github.com>
2021-07-22 09:09:49 +00:00

104 lines
4.6 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models, tools
class ReportProjectTaskUser(models.Model):
_name = "report.project.task.user"
_description = "Tasks Analysis"
_order = 'name desc, project_id'
_auto = False
name = fields.Char(string='Task', readonly=True)
user_id = fields.Many2one('res.users', string='Assigned To', readonly=True)
create_date = fields.Datetime("Create Date", readonly=True)
date_assign = fields.Datetime(string='Assignment Date', readonly=True)
date_end = fields.Datetime(string='Ending Date', readonly=True)
date_deadline = fields.Date(string='Deadline', readonly=True)
date_last_stage_update = fields.Datetime(string='Last Stage Update', readonly=True)
project_id = fields.Many2one('project.project', string='Project', readonly=True)
working_days_close = fields.Float(string='Working Days to Close',
digits=(16,2), readonly=True, group_operator="avg",
help="Number of Working Days to close the task")
working_days_open = fields.Float(string='Working Days to Assign',
digits=(16,2), readonly=True, group_operator="avg",
help="Number of Working Days to open the task")
delay_endings_days = fields.Float(string='Days to Deadline', digits=(16, 2), group_operator="avg", readonly=True)
nbr = fields.Integer('# of Tasks', readonly=True) # TDE FIXME master: rename into nbr_tasks
working_hours_open = fields.Float(string='Working Hours to Assign', digits=(16, 2), readonly=True, group_operator="avg", help="Number of Working Hours to open the task")
working_hours_close = fields.Float(string='Working Hours to Close', digits=(16, 2), readonly=True, group_operator="avg", help="Number of Working Hours to close the task")
rating_last_value = fields.Float('Rating Value (/5)', group_operator="avg", readonly=True, groups="project.group_project_rating")
priority = fields.Selection([
('0', 'Low'),
('1', 'Normal'),
('2', 'High')
], readonly=True, string="Priority")
state = fields.Selection([
('normal', 'In Progress'),
('blocked', 'Blocked'),
('done', 'Ready for Next Stage')
], string='Kanban State', readonly=True)
company_id = fields.Many2one('res.company', string='Company', readonly=True)
partner_id = fields.Many2one('res.partner', string='Customer', readonly=True)
stage_id = fields.Many2one('project.task.type', string='Stage', readonly=True)
task_id = fields.Many2one('project.task', string='Tasks', readonly=True)
def _select(self):
select_str = """
SELECT
(select 1 ) AS nbr,
t.id as id,
t.id as task_id,
t.create_date as create_date,
t.date_assign as date_assign,
t.date_end as date_end,
t.date_last_stage_update as date_last_stage_update,
t.date_deadline as date_deadline,
t.user_id,
t.project_id,
t.priority,
t.name as name,
t.company_id,
t.partner_id,
t.stage_id as stage_id,
t.kanban_state as state,
NULLIF(t.rating_last_value, 0) as rating_last_value,
t.working_days_close as working_days_close,
t.working_days_open as working_days_open,
t.working_hours_open as working_hours_open,
t.working_hours_close as working_hours_close,
(extract('epoch' from (t.date_deadline-(now() at time zone 'UTC'))))/(3600*24) as delay_endings_days
"""
return select_str
def _group_by(self):
group_by_str = """
GROUP BY
t.id,
t.create_date,
t.write_date,
t.date_assign,
t.date_end,
t.date_deadline,
t.date_last_stage_update,
t.user_id,
t.project_id,
t.priority,
t.name,
t.company_id,
t.partner_id,
t.stage_id
"""
return group_by_str
def init(self):
tools.drop_view_if_exists(self._cr, self._table)
self._cr.execute("""
CREATE view %s as
%s
FROM project_task t
WHERE t.active = 'true'
%s
""" % (self._table, self._select(), self._group_by()))