diff --git a/project_report/report/project_budget_hrs_analysis.py b/project_report/report/project_budget_hrs_analysis.py
index 7d6f4f9..0d3b02c 100755
--- a/project_report/report/project_budget_hrs_analysis.py
+++ b/project_report/report/project_budget_hrs_analysis.py
@@ -22,6 +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")
pricing_type = fields.Selection([
('fixed_rate', 'Fixed rate'),
('employee_rate', 'Consultant rate')
@@ -57,15 +58,18 @@ class BudgetHrsAnalysis(models.Model):
partner_id,
employee_id,
hours_type,
- hours from (
+ 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 Hours' as hours_type,
+ 'Budgeted' as hours_type,
pro_emp.budgeted_qty as hours,
+ (date - date_start) as timeline,
pro.*
FROM
project_project PRO
@@ -80,8 +84,9 @@ class BudgetHrsAnalysis(models.Model):
null::int AS employee_id,
date_start AS startdate,
date AS enddate,
- 'Budgeted Hours' as hours_type,
+ 'Budgeted' as hours_type,
pro.budgeted_hours2 as hours,
+ (date - date_start) as timeline,
pro.*
FROM
project_project PRO
@@ -96,8 +101,10 @@ 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 Hours' as hours_type,
+ 'Actual' as hours_type,
unit_amount as hours,
+ (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.*
FROM project_project PRO
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
@@ -113,8 +120,10 @@ 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 Hours' as hours_type,
+ 'Actual' as hours_type,
unit_amount as hours,
+ (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.*
FROM project_project PRO
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
@@ -129,8 +138,10 @@ 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 Hours' as hours_type,
+ 'Actual' as hours_type,
unit_amount as hours,
+ (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.*
FROM project_project PRO
LEFT JOIN account_analytic_account AA ON PRO.analytic_account_id = AA.id
diff --git a/project_report/report/project_budget_hrs_analysis_views.xml b/project_report/report/project_budget_hrs_analysis_views.xml
index 9f9ddf3..1ebb611 100755
--- a/project_report/report/project_budget_hrs_analysis_views.xml
+++ b/project_report/report/project_budget_hrs_analysis_views.xml
@@ -37,6 +37,7 @@
+
diff --git a/project_report/static/src/js/graph_renderer.js b/project_report/static/src/js/graph_renderer.js
index 8ee2aaa..f4607d6 100755
--- a/project_report/static/src/js/graph_renderer.js
+++ b/project_report/static/src/js/graph_renderer.js
@@ -220,9 +220,14 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
dataset[referenceColor] = dataset[referenceColor][0]
} */
}
+ var label_res = dataset.label;
+ if (self.resModel == 'project.budget.hrs.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);
+ }
return {
- text: self._shortenLabel(dataset.label),
- fullText: dataset.label,
+ text: self._shortenLabel(label_res),
+ fullText: label_res,
fillStyle: r,
hidden: !chart.isDatasetVisible(i),
lineCap: dataset.borderCapStyle,
@@ -291,6 +296,10 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
}
value = this._formatValue(item.yLabel);
boxColor = dataset.backgroundColor;
+ var r = dataset.backgroundColor;
+ if ((dataset.backgroundColor instanceof Array) && (dataset.backgroundColor.length>=1)) {
+ boxColor = dataset.backgroundColor[item.index]
+ }
} else if (this.state.mode === 'horizontalBar') {
label = this._relabelling(label, dataset.originIndex);
if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) {
@@ -298,6 +307,9 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
}
value = this._formatValue(item.xLabel);
boxColor = dataset.backgroundColor;
+ if ((dataset.backgroundColor instanceof Array) && (dataset.backgroundColor.length>=1)) {
+ boxColor = dataset.backgroundColor[item.index]
+ }
}
else if (this.state.mode === 'line') {
label = this._relabelling(label, dataset.originIndex);
@@ -569,9 +581,8 @@ 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') {
- 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]);
//var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', ''));
_.map(groupedData, (y) => {
if (y.length > 1) {
@@ -648,7 +659,8 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined;
// set dataset color
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 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;
}
@@ -670,7 +682,6 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
dataset.backgroundColor = color;
}
});
-
// prepare options
var options = this._prepareOptions(data.datasets.length);
// create chart
@@ -705,7 +716,8 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
var data = this._prepareData(dataPoints);
if (self.resModel == 'project.budget.hrs.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 Hours', '').replace('Budgeted Hours', '').split("/")[0]);
+ 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]);