Report updated default view month and timeline measure first report hide

This commit is contained in:
projectsodoo 2021-03-01 19:32:42 +05:30
parent f34cae8f72
commit 47f0c21b45
4 changed files with 78 additions and 21 deletions

View File

@ -22,7 +22,7 @@ class BudgetHrsAnalysis(models.Model):
employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True)
hours_type = fields.Char(string="Hours Type", readonly=True)
hours = fields.Float("Number of Hours", digits=(16, 2), readonly=True, group_operator="sum")
timeline = fields.Float("Timeline", digits=(16, 2), readonly=True, group_operator="sum")
#timeline = fields.Float("Timeline", digits=(16, 2), readonly=True, group_operator="sum")
pricing_type = fields.Selection([
('fixed_rate', 'Fixed rate'),
('employee_rate', 'Consultant rate')
@ -58,8 +58,8 @@ class BudgetHrsAnalysis(models.Model):
partner_id,
employee_id,
hours_type,
hours,
timeline
hours
--timeline
from (
SELECT
pro.id AS project_id,
@ -67,9 +67,9 @@ class BudgetHrsAnalysis(models.Model):
pro_emp.employee_id AS employee_id,
date_start AS startdate,
date AS enddate,
'Budgeted' as hours_type,
'Budgeted Hours' as hours_type,
pro_emp.budgeted_qty as hours,
pro_emp.budgeted_qty/8 as timeline,
--pro_emp.budgeted_qty/8 as timeline,
--(date - date_start) as timeline,
pro.*
FROM
@ -85,10 +85,10 @@ class BudgetHrsAnalysis(models.Model):
null::int AS employee_id,
date_start AS startdate,
date AS enddate,
'Budgeted' as hours_type,
'Budgeted Hours' as hours_type,
pro.budgeted_hours2 as hours,
--(date - date_start) as timeline,
pro.budgeted_hours2/8 as timeline,
--pro.budgeted_hours2/8 as timeline,
pro.*
FROM
project_project PRO
@ -103,9 +103,9 @@ class BudgetHrsAnalysis(models.Model):
AAL.employee_id AS employee_id,
coalesce(pro.date_start, (select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id)) AS startdate,
(select max(al.end_datetime::date) from account_analytic_line as al) as enddate,
'Actual' as hours_type,
'Actual Hours' as hours_type,
unit_amount as hours,
unit_amount/8 as timeline,
--unit_amount/8 as timeline,
--(select max(al.end_datetime::date) from account_analytic_line as al) -
--coalesce(pro.date_start, (select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id)) AS timeline,
pro.*
@ -123,9 +123,9 @@ class BudgetHrsAnalysis(models.Model):
AAL.employee_id AS employee_id,
coalesce(pro.date_start, (select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id)) AS startdate,
(select max(al.end_datetime::date) from account_analytic_line as al) as enddate,
'Actual' as hours_type,
'Actual Hours' as hours_type,
unit_amount as hours,
unit_amount/8 as timeline,
--unit_amount/8 as timeline,
--(select max(al.end_datetime::date) from account_analytic_line as al) -
--(select min(al.start_datetime::date) from account_analytic_line as al where pro.id=al.project_id) AS timeline,
pro.*
@ -142,9 +142,9 @@ class BudgetHrsAnalysis(models.Model):
AAL.employee_id AS employee_id,
pro.date_start AS startdate,
(select max(al.end_datetime::date) from account_analytic_line as al) as enddate,
'Actual' as hours_type,
'Actual Hours' as hours_type,
unit_amount as hours,
unit_amount/8 as timeline,
--unit_amount/8 as timeline,
--(select max(al.end_datetime::date) from account_analytic_line as al) - pro.date_start AS timeline,
--DATE_PART('day', AGE(select max(al.end_datetime::date) from account_analytic_line, pro.date_start)) AS timeline,
pro.*

View File

@ -37,7 +37,7 @@
<!--<field name="timesheet_date" optional="hide"/>-->
<field name="hours_type"/>
<field name="hours"/>
<field name="timeline"/>
<!--<field name="timeline"/>-->
<field name="parent_project" optional="hide"/>
</tree>
</field>

View File

@ -63,8 +63,8 @@
<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="Start Date" name="sdate" domain="[]" context="{'group_by':'start_date:day'}"/>
<filter string="End Date" name="edate" domain="[]" context="{'group_by':'end_date:day'}"/>
<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'}"/>-->
<filter string="Hours type" name="group_by_timeline_type" context="{'group_by':'timeline_type'}"/>
</group>

View File

@ -221,7 +221,8 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
} */
}
var label_res = dataset.label;
if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
//if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
if (self.resModel == 'project.timeline.report') {
var measure_value = self.fields[self.state.measure].string.split(" ").splice(-1);
label_res = label_res.replace("Actual", "Actual " + measure_value).replace("Budgeted", "Budgeted " + measure_value);
}
@ -585,7 +586,27 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
var data = this._prepareData(dataPoints);
// this.title = 'Time Line';
if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
if (self.resModel == 'project.budget.hrs.report') {
var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', ''));
_.map(groupedData, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
}
});
}
if (self.resModel == 'project.timeline.report') {
var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual', '').replace('Budgeted', '').split("/")[0]);
//var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', ''));
_.map(groupedData, (y) => {
@ -665,7 +686,14 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
/* if (self.state.stacked && dataset.label.includes("Actual")) {
dataset.stack = 1;
}*/
if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
if (self.resModel == 'project.budget.hrs.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) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else if (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) {
var color = self._getColor(index);
@ -724,7 +752,30 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
//console.log("datappppppppppp", dataPoints);
if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
if (self.resModel == 'project.budget.hrs.report') {
var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', ''));
//var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual', '').replace('Budgeted', '').split("/")[0]);
_.map(groupedData, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]);
}
});
}
if (self.resModel == 'project.timeline.report') {
//var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', '').split("/")[0]);
var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual', '').replace('Budgeted', '').split("/")[0]);
_.map(groupedData, (y) => {
@ -797,7 +848,13 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
/*if (self.state.stacked && dataset.label.includes("Actual")) {
dataset.stack = 1;
}*/
if ((self.resModel == 'project.budget.hrs.report') || (self.resModel == 'project.timeline.report')) {
if (self.resModel == 'project.budget.hrs.report') {
if (dataset.label.indexOf("Actual Hours") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else if (self.resModel == 'project.timeline.report') {
if (dataset.label.indexOf("Actual") === -1 && dataset.label.toLowerCase().indexOf("Budgeted") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;