Updated timeline report

This commit is contained in:
projectsodoo 2021-03-01 11:39:34 +05:30
parent c7aa914c72
commit d019b240f5
3 changed files with 15 additions and 57 deletions

View File

@ -19,7 +19,7 @@ class ProjectTimelineReport(models.Model):
start_date = fields.Date(string='Start Date', readonly=True)
end_date = fields.Date(string='End Date', readonly=True)
partner_id = fields.Many2one('res.partner', string='Client', readonly=True)
employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True)
#employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True)
timeline_type = fields.Char(string="Timeline Type", readonly=True)
timeline = fields.Float("Timeline", digits=(16, 2), readonly=True, group_operator="sum")
hours = fields.Float("Number of Hours", digits=(16, 2), readonly=True, group_operator="sum")
@ -46,81 +46,38 @@ class ProjectTimelineReport(models.Model):
pricing_type as pricing_type,
project_type as project_type,
partner_id,
employee_id,
timeline_type,
hours,
timeline from (
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parentproject,
pro_emp.employee_id AS employee_id,
date_start AS startdate,
date AS enddate,
'Budgeted' as timeline_type,
--DATE_PART('day', AGE(date, date_start)) AS timeline,
pro_emp.budgeted_qty as hours,
pro_emp.budgeted_qty/8 as timeline,
pro.*
FROM
project_project PRO
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
Where
pro.active = 't'
and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parentproject,
null::int AS employee_id,
date_start AS startdate,
date AS enddate,
'Budgeted' as timeline_type,
--DATE_PART('day', AGE(date, date_start)) AS timeline,
pro.budgeted_hours2 as hours,
pro.budgeted_hours2/8 as timeline,
DATE_PART('day', AGE(date, date_start)) AS timeline,
pro.*
FROM
project_project PRO
Where
pro.active = 't'
and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_no_limit'
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parentproject,
AAL.employee_id AS employee_id,
start_datetime::DATE AS startdate,
end_datetime::DATE AS enddate,
(select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id limit 1) as startdate,
(select max(al.end_datetime::date) from account_analytic_line as al where pro.id=al.project_id) as enddate,
'Actual' as timeline_type,
--DATE_PART('day', AGE(end_datetime, start_datetime)) AS timeline,
unit_amount as hours,
unit_amount/8 as timeline,
pro.*
FROM project_project PRO
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id and AAL.employee_id = pro_emp.employee_id
Where
PRO.active = 't' and PRO.pricing_type = 'employee_rate'
Union all
SELECT
pro.id AS project_id,
(select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parentproject,
AAL.employee_id AS employee_id,
start_datetime::DATE AS startdate,
end_datetime::DATE AS enddate,
'Actual' as timeline_type,
--DATE_PART('day', AGE(end_datetime, start_datetime)) AS timeline,
unit_amount as hours,
unit_amount/8 as timeline,
sum(unit_amount) as hours,
DATE_PART('day', AGE((select max(al.end_datetime::date) from account_analytic_line as al where pro.id=al.project_id), (select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id))) AS timeline,
pro.*
FROM project_project PRO
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id
--and AAL.employee_id = pro_emp.employee_id
Where
PRO.active = 't'
and PRO.pricing_type = 'fixed_rate'
group by pro.id
) as res
order by
project_id desc,

View File

@ -33,9 +33,10 @@
<field name="project_id"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="employee_id"/>
<!--<field name="employee_id"/>-->
<!--<field name="timesheet_date" optional="hide"/>-->
<field name="timeline_type"/>
<field name="hours"/>
<field name="timeline"/>
<field name="parent_project" optional="hide"/>
</tree>
@ -50,7 +51,7 @@
<search string="Budget Analysis">
<field name="project_id"/>
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
<field name="employee_id"/>
<!--<field name="employee_id"/>-->
<field name="start_date"/>
<field name="end_date"/>
<!--<field name="timesheet_date"/>-->
@ -61,7 +62,7 @@
<group expand="1" string="Group By">
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
<filter string="Client" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>
<filter string="Consultant" name="group_by_employee_id" context="{'group_by':'employee_id'}"/>
<!--<filter string="Consultant" name="group_by_employee_id" context="{'group_by':'employee_id'}"/>-->
<filter string="Start Date" name="sdate" domain="[]" context="{'group_by':'start_date:month'}"/>
<filter string="End Date" name="edate" domain="[]" context="{'group_by':'end_date:month'}"/>
<!--<filter string="Timesheet Date" name="tdate" domain="[]" context="{'group_by':'timesheet_date:day'}"/>-->

View File

@ -662,9 +662,9 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
// used when stacked
dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined;
// set dataset color
if (self.state.stacked && dataset.label.includes("Actual")) {
/* if (self.state.stacked && dataset.label.includes("Actual")) {
dataset.stack = 1;
}
}*/
if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
//if (dataset.label.indexOf("Actual Hours") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours") === -1) {
if (dataset.label.indexOf("Actual") === -1 && dataset.label.toLowerCase().indexOf("Budgeted") === -1) {
@ -794,9 +794,9 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
// used when stacked
dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined;
// set dataset color
if (self.state.stacked && dataset.label.includes("Actual")) {
/*if (self.state.stacked && dataset.label.includes("Actual")) {
dataset.stack = 1;
}
}*/
if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
if (dataset.label.indexOf("Actual") === -1 && dataset.label.toLowerCase().indexOf("Budgeted") === -1) {
var color = self._getColor(index);