From 47f0c21b458477e5a1612fa5ae99bc2009c77777 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Mon, 1 Mar 2021 19:32:42 +0530 Subject: [PATCH 01/11] Report updated default view month and timeline measure first report hide --- .../report/project_budget_hrs_analysis.py | 26 +++---- .../project_budget_hrs_analysis_views.xml | 2 +- .../report/project_timeline_report_views.xml | 4 +- .../static/src/js/graph_renderer.js | 67 +++++++++++++++++-- 4 files changed, 78 insertions(+), 21 deletions(-) diff --git a/project_report/report/project_budget_hrs_analysis.py b/project_report/report/project_budget_hrs_analysis.py index 90c5ef6..f3e07e2 100755 --- a/project_report/report/project_budget_hrs_analysis.py +++ b/project_report/report/project_budget_hrs_analysis.py @@ -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.* diff --git a/project_report/report/project_budget_hrs_analysis_views.xml b/project_report/report/project_budget_hrs_analysis_views.xml index 1ebb611..7feee4e 100755 --- a/project_report/report/project_budget_hrs_analysis_views.xml +++ b/project_report/report/project_budget_hrs_analysis_views.xml @@ -37,7 +37,7 @@ - + diff --git a/project_report/report/project_timeline_report_views.xml b/project_report/report/project_timeline_report_views.xml index 2ad626b..a843eca 100755 --- a/project_report/report/project_timeline_report_views.xml +++ b/project_report/report/project_timeline_report_views.xml @@ -63,8 +63,8 @@ - - + + diff --git a/project_report/static/src/js/graph_renderer.js b/project_report/static/src/js/graph_renderer.js index b363d65..db19740 100755 --- a/project_report/static/src/js/graph_renderer.js +++ b/project_report/static/src/js/graph_renderer.js @@ -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; From 5aa284770a8479d19f1b6ec5e95e7ca0ac620117 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Mon, 1 Mar 2021 20:00:26 +0530 Subject: [PATCH 02/11] compare project condition js updated --- project_report/static/src/js/graph_renderer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project_report/static/src/js/graph_renderer.js b/project_report/static/src/js/graph_renderer.js index db19740..84d7d8c 100755 --- a/project_report/static/src/js/graph_renderer.js +++ b/project_report/static/src/js/graph_renderer.js @@ -587,7 +587,7 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); // 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', '')); + var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', '').split("/")[0]); _.map(groupedData, (y) => { if (y.length > 1) { var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); @@ -753,7 +753,7 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); //console.log("datappppppppppp", dataPoints); 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 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) { @@ -778,6 +778,7 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); 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]); + console.log("groupedData ", groupedData); _.map(groupedData, (y) => { if (y.length > 1) { var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); From 721e3434e917f3eace310e314e635692a39f305a Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Tue, 2 Mar 2021 14:46:19 +0530 Subject: [PATCH 03/11] Timeline filter added --- project_report/report/project_timeline_report_views.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/project_report/report/project_timeline_report_views.xml b/project_report/report/project_timeline_report_views.xml index a843eca..fd6bb19 100755 --- a/project_report/report/project_timeline_report_views.xml +++ b/project_report/report/project_timeline_report_views.xml @@ -58,6 +58,7 @@ + @@ -77,7 +78,7 @@ project.timeline.report graph,tree,pivot - {'search_default_group_by_project': 1,'search_default_sdate': 1,'search_default_edate': 1,'search_default_group_by_timeline_type': 1, 'default_res_model':'project.timeline.report'} + {'search_default_notfixed':1,'search_default_group_by_project': 1,'search_default_sdate': 1,'search_default_edate': 1,'search_default_group_by_timeline_type': 1, 'default_res_model':'project.timeline.report'} Date: Tue, 2 Mar 2021 16:34:28 +0530 Subject: [PATCH 04/11] Updated default report in all 3 reports --- project_report/report/project_budget_amt_analysis_views.xml | 3 ++- project_report/report/project_budget_hrs_analysis_views.xml | 3 ++- project_report/report/project_timeline_report_views.xml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/project_report/report/project_budget_amt_analysis_views.xml b/project_report/report/project_budget_amt_analysis_views.xml index 885ccf3..5ea81f6 100755 --- a/project_report/report/project_budget_amt_analysis_views.xml +++ b/project_report/report/project_budget_amt_analysis_views.xml @@ -59,6 +59,7 @@ + @@ -78,7 +79,7 @@ project.budget.amt.report graph,tree,pivot - {'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1, 'default_res_model': 'project.budget.amt.report'} + {'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1, 'default_res_model': 'project.budget.amt.report', 'search_default_notfixed':1} + @@ -78,7 +79,7 @@ project.budget.hrs.report graph,tree,pivot - {'search_default_group_by_project': 1,'search_default_sdate': 1,'search_default_edate': 1,'search_default_group_by_hours_type': 1, 'default_res_model': 'project.budget.hrs.report'} + {'search_default_group_by_project': 1,'search_default_sdate': 1,'search_default_edate': 1,'search_default_group_by_hours_type': 1, 'default_res_model': 'project.budget.hrs.report','search_default_notfixed':1} project.timeline.report graph,tree,pivot - {'search_default_notfixed':1,'search_default_group_by_project': 1,'search_default_sdate': 1,'search_default_edate': 1,'search_default_group_by_timeline_type': 1, 'default_res_model':'project.timeline.report'} + {'search_default_group_by_project': 1,'search_default_sdate': 1,'search_default_edate': 1,'search_default_group_by_timeline_type': 1, 'default_res_model':'project.timeline.report', 'search_default_notfixed':1} Date: Tue, 2 Mar 2021 18:15:35 +0530 Subject: [PATCH 05/11] Timeline filter month to day updated --- project_report/report/project_timeline_report_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project_report/report/project_timeline_report_views.xml b/project_report/report/project_timeline_report_views.xml index c380cb5..068dd9a 100755 --- a/project_report/report/project_timeline_report_views.xml +++ b/project_report/report/project_timeline_report_views.xml @@ -64,8 +64,8 @@ - - + + From 0d09f22f27a9b47ceacbd3f0c3b295818faef086 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Tue, 2 Mar 2021 23:20:09 +0530 Subject: [PATCH 06/11] Timeline order by and label updated --- project_report/report/project_timeline_report.py | 5 +++-- .../report/project_timeline_report_views.xml | 2 +- project_report/static/src/js/graph_renderer.js | 12 +++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/project_report/report/project_timeline_report.py b/project_report/report/project_timeline_report.py index 6318909..78dc9a8 100755 --- a/project_report/report/project_timeline_report.py +++ b/project_report/report/project_timeline_report.py @@ -8,7 +8,7 @@ class ProjectTimelineReport(models.Model): _name = "project.timeline.report" _description = "Project Timeline Report" - #_order = 'project_id' + _order = 'project_id desc, timeline_type asc' _auto = False #analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', readonly=True) @@ -80,6 +80,7 @@ class ProjectTimelineReport(models.Model): Where PRO.active = 't' group by pro.id + order by project_id desc, timeline_type asc ) as res order by project_id desc, @@ -87,7 +88,7 @@ class ProjectTimelineReport(models.Model): --end_date desc, --pricing_type, --project_type, - timeline_type desc + timeline_type asc --employee_id )""" % (self._table,)) diff --git a/project_report/report/project_timeline_report_views.xml b/project_report/report/project_timeline_report_views.xml index 068dd9a..13e23ab 100755 --- a/project_report/report/project_timeline_report_views.xml +++ b/project_report/report/project_timeline_report_views.xml @@ -78,7 +78,7 @@ project.timeline.report graph,tree,pivot - {'search_default_group_by_project': 1,'search_default_sdate': 1,'search_default_edate': 1,'search_default_group_by_timeline_type': 1, 'default_res_model':'project.timeline.report', 'search_default_notfixed':1} + {'search_default_group_by_project': 1, 'search_default_group_by_timeline_type': 1, 'search_default_notfixed':1, 'search_default_sdate': 1,'search_default_edate': 1, 'default_res_model':'project.timeline.report'} 1) { datasetLabel = this.state.origins[dataPt.originIndex] + (datasetLabel ? ('/' + datasetLabel) : ''); @@ -294,6 +295,7 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); label = this._relabelling(label, dataset.originIndex); if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) { label = label + "/" + dataset.label; + label = dataset.label; } value = this._formatValue(item.yLabel); boxColor = dataset.backgroundColor; @@ -304,7 +306,8 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); } else if (this.state.mode === 'horizontalBar') { label = this._relabelling(label, dataset.originIndex); if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) { - label = label + "/" + dataset.label; + //label = label + "/" + dataset.label; + label = dataset.label; } value = this._formatValue(item.xLabel); boxColor = dataset.backgroundColor; @@ -770,7 +773,7 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); }); y[0].backgroundColor = maxA; y[1].backgroundColor = self._getColor(1); - var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]); + //var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]); } }); } @@ -778,7 +781,6 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); 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]); - console.log("groupedData ", groupedData); _.map(groupedData, (y) => { if (y.length > 1) { var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]); @@ -794,7 +796,7 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); }); y[0].backgroundColor = maxA; y[1].backgroundColor = self._getColor(1); - var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]); + //var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]); } }); } From 23405a5407c3b8d5c7f2d4db367edd6403ef8cfd Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Tue, 2 Mar 2021 23:27:21 +0530 Subject: [PATCH 07/11] js label cond updated --- project_report/static/src/js/graph_renderer.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/project_report/static/src/js/graph_renderer.js b/project_report/static/src/js/graph_renderer.js index ead4fc5..93447ba 100755 --- a/project_report/static/src/js/graph_renderer.js +++ b/project_report/static/src/js/graph_renderer.js @@ -145,8 +145,8 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); _getDatasetLabel: function (dataPt) { if (_.contains(['bar', 'horizontalBar', 'line'], this.state.mode)) { // ([origin] + second to last groupBys) or measure - //var datasetLabel = dataPt.labels.slice(1).join("/"); - var datasetLabel = dataPt.labels.slice(0).join("/"); + var datasetLabel = dataPt.labels.slice(1).join("/"); + //var datasetLabel = dataPt.labels.slice(0).join("/"); if (this.state.origins.length > 1) { datasetLabel = this.state.origins[dataPt.originIndex] + (datasetLabel ? ('/' + datasetLabel) : ''); @@ -295,7 +295,6 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); label = this._relabelling(label, dataset.originIndex); if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) { label = label + "/" + dataset.label; - label = dataset.label; } value = this._formatValue(item.yLabel); boxColor = dataset.backgroundColor; @@ -306,8 +305,7 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); } else if (this.state.mode === 'horizontalBar') { label = this._relabelling(label, dataset.originIndex); if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) { - //label = label + "/" + dataset.label; - label = dataset.label; + label = label + "/" + dataset.label; } value = this._formatValue(item.xLabel); boxColor = dataset.backgroundColor; From 128ce82d23f9fe8f7c7ceb0690ca824aaaec43e8 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Wed, 3 Mar 2021 10:12:08 +0530 Subject: [PATCH 08/11] Js label valid updated --- .../static/src/js/graph_renderer.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/project_report/static/src/js/graph_renderer.js b/project_report/static/src/js/graph_renderer.js index 93447ba..4cec265 100755 --- a/project_report/static/src/js/graph_renderer.js +++ b/project_report/static/src/js/graph_renderer.js @@ -145,7 +145,13 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); _getDatasetLabel: function (dataPt) { if (_.contains(['bar', 'horizontalBar', 'line'], this.state.mode)) { // ([origin] + second to last groupBys) or measure - var datasetLabel = dataPt.labels.slice(1).join("/"); + //console.log("dataPt.labels", dataPt.labels, dataPt.labels.length, typeof dataPt.labels, self.resModel, this.resModel); + if ((dataPt.labels.length > 2) && (this.resModel == 'project.timeline.report' || this.resModel == 'project.budget.hrs.report')) { + var datasetLabel = dataPt.labels.slice(0).join("/"); + } + else { + var datasetLabel = dataPt.labels.slice(1).join("/"); + } //var datasetLabel = dataPt.labels.slice(0).join("/"); if (this.state.origins.length > 1) { datasetLabel = this.state.origins[dataPt.originIndex] + @@ -294,7 +300,13 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); if (this.state.mode === 'bar') { label = this._relabelling(label, dataset.originIndex); if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) { - label = label + "/" + dataset.label; + if (this.resModel == 'project.timeline.report' || this.resModel == 'project.budget.hrs.report') + { + label = dataset.label; + } + else{ + label = label + "/" + dataset.label; + } } value = this._formatValue(item.yLabel); boxColor = dataset.backgroundColor; @@ -305,7 +317,13 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); } else if (this.state.mode === 'horizontalBar') { label = this._relabelling(label, dataset.originIndex); if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) { - label = label + "/" + dataset.label; + if (this.resModel == 'project.timeline.report' || this.resModel == 'project.budget.hrs.report') + { + label = dataset.label; + } + else{ + label = label + "/" + dataset.label; + } } value = this._formatValue(item.xLabel); boxColor = dataset.backgroundColor; From 4a6d324feca05f1eef232ef0ed61cc8f92a07068 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Fri, 5 Mar 2021 10:18:35 +0530 Subject: [PATCH 09/11] New timesheet report added --- project_report/__manifest__.py | 1 + project_report/report/__init__.py | 1 + .../report/project_timesheet_report.py | 81 +++++++++++++++++++ .../report/project_timesheet_report_views.xml | 56 +++++++++++++ project_report/security/ir.model.access.csv | 4 +- 5 files changed, 142 insertions(+), 1 deletion(-) create mode 100755 project_report/report/project_timesheet_report.py create mode 100755 project_report/report/project_timesheet_report_views.xml diff --git a/project_report/__manifest__.py b/project_report/__manifest__.py index 549e4b3..8cae31e 100755 --- a/project_report/__manifest__.py +++ b/project_report/__manifest__.py @@ -20,6 +20,7 @@ 'report/project_budget_hrs_analysis_views.xml', 'report/project_budget_amt_analysis_views.xml', 'report/project_timeline_report_views.xml', + 'report/project_timesheet_report_views.xml', ], 'qweb': [ "static/src/xml/base.xml", diff --git a/project_report/report/__init__.py b/project_report/report/__init__.py index 643d4d2..d635724 100755 --- a/project_report/report/__init__.py +++ b/project_report/report/__init__.py @@ -4,3 +4,4 @@ from . import project_budget_hrs_analysis from . import project_budget_amt_analysis from . import project_timeline_report +from . import project_timesheet_report diff --git a/project_report/report/project_timesheet_report.py b/project_report/report/project_timesheet_report.py new file mode 100755 index 0000000..bfe6d40 --- /dev/null +++ b/project_report/report/project_timesheet_report.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, tools, api +from datetime import datetime, time, timedelta +from odoo.tools.float_utils import float_round + +class ProjectTimelineReport(models.Model): + + _name = "project.timesheet.report" + _description = "Project Timesheet Report" + _order = 'start_date desc, project_id desc' + _auto = False + + start_date = fields.Date(string='Start Date', readonly=True) + employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True) + project_id = fields.Many2one('project.project', string='Project', readonly=True) + #sub_project = fields.Many2one('project.project', string='Sub Project', readonly=True) + duration = fields.Float('Duration', readonly=True) + timestamp = fields.Char('Timestamp', readonly=True) + task_id = fields.Many2one('project.task', string='Task', readonly=True) + description = fields.Char('Description', readonly=True) + sub_project = fields.Many2many('project.project', compute='_compute_related_subproject') + + @api.depends('project_id') + def _compute_related_subproject(self): + for val in self: + val.sub_project = val.project_id.sub_project.ids + + @api.model + def export_data(self, fields): + index = range(len(fields)) + fields_name = dict(zip(fields, index)) + res = super(ProjectTimelineReport, self).export_data(fields) + for index, val in enumerate(res['datas']): + if fields_name.get('start_date') is not None: + tdateindex = fields_name.get('start_date') + tdate = res['datas'][index][tdateindex] + if tdate: + res['datas'][index][tdateindex] = datetime.strftime(tdate, "%d/%m/%Y") + if fields_name.get('task_id') is not None: + taskindex = fields_name.get('task_id') + ttask = res['datas'][index][taskindex] + if type(ttask) == bool: + res['datas'][index][taskindex] = '' + if fields_name.get('project_id') is not None: + projectindex = fields_name.get('project_id') + project = res['datas'][index][projectindex] + if type(project) == bool: + res['datas'][index][projectindex] = '' + if fields_name.get('sub_project') is not None: + subindex = fields_name.get('sub_project') + subproject = res['datas'][index][subindex] + if type(subproject) == bool: + res['datas'][index][subindex] = '' + if fields_name.get('duration') is not None: + durationindex = fields_name.get('duration') + duration = res['datas'][index][durationindex] and float(res['datas'][index][durationindex]) + if duration: + duration_time = tools.format_duration(duration) + res['datas'][index][durationindex] = duration_time + return res + + def init(self): + '''Create the view''' + tools.drop_view_if_exists(self._cr, self._table) + self._cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + SELECT + ROW_NUMBER() OVER() as id, + start_datetime::date as start_date, + employee_id, + project_id, + unit_amount as duration, + CONCAT(to_char(start_datetime at time zone 'utc', 'HH24:MI'), '-', to_char(end_datetime at time zone 'utc', 'HH24:MI')) as timestamp, + task_id, + name as description + from account_analytic_line + )""" % (self._table,)) + + diff --git a/project_report/report/project_timesheet_report_views.xml b/project_report/report/project_timesheet_report_views.xml new file mode 100755 index 0000000..09ad54b --- /dev/null +++ b/project_report/report/project_timesheet_report_views.xml @@ -0,0 +1,56 @@ + + + + + + project.timesheet.report.tree + project.timesheet.report + + + + + + + + + + + + + + + + + project.timesheet.report.search + project.timesheet.report + + + + + + + + + + + + + + + + + + Timesheets Report + project.timesheet.report + tree + + {} + + + + + diff --git a/project_report/security/ir.model.access.csv b/project_report/security/ir.model.access.csv index f653d5a..d29c722 100755 --- a/project_report/security/ir.model.access.csv +++ b/project_report/security/ir.model.access.csv @@ -6,4 +6,6 @@ access_project_budget_hrs_report_user,project.budget.hrs.report.user,model_proje access_project_budget_amt_report_user,project.budget.amt.report.user,model_project_budget_amt_report,project.group_project_user,1,0,0,0 access_project_create_expense_user,access_project_create_expense_project_user,model_project_create_expense,project.group_project_user,1,0,0,0 access_project_timeline_report_manager,project.timeline.report,model_project_timeline_report,project.group_project_manager,1,1,1,1 -access_project_timeline_report_user,project.timeline.report,model_project_timeline_report,project.group_project_user,1,0,0,0 \ No newline at end of file +access_project_timeline_report_user,project.timeline.report,model_project_timeline_report,project.group_project_user,1,0,0,0 +access_project_timesheet_report_manager,project.timesheet.report,model_project_timesheet_report,project.group_project_manager,1,1,1,1 +access_project_timesheet_report_user,project.timesheet.report,model_project_timesheet_report,project.group_project_user,1,0,0,0 \ No newline at end of file From 3096aad0c8b89693d9527bde32ed44c1a26d933b Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Fri, 5 Mar 2021 10:54:11 +0530 Subject: [PATCH 10/11] Timesheet export method improved --- cor_custom/models/analytic.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index dc79a27..458a670 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -133,38 +133,46 @@ class AccountAnalyticLine(models.Model): res = super(AccountAnalyticLine, self).export_data(fields) for index, val in enumerate(res['datas']): #print("task_id", fields_name) - if fields_name.get('date') and fields_name.get('date') >= 0: + #if fields_name.get('date') and fields_name.get('date') >= 0: + if fields_name.get('date') is not None: tdateindex = fields_name.get('date') tdate = res['datas'][index][tdateindex] if tdate: res['datas'][index][tdateindex] = datetime.strftime(tdate, "%d/%m/%Y") - if fields_name.get('start_datetime') and fields_name.get('start_datetime') >= 0: + #if fields_name.get('start_datetime') and fields_name.get('start_datetime') >= 0: + if fields_name.get('start_datetime') is not None: start_datetime_index = fields_name.get('start_datetime') start_datetime = res['datas'][index][start_datetime_index] if start_datetime: res['datas'][index][start_datetime_index] = datetime.strftime(start_datetime, "%d/%m/%Y %H:%M") - if fields_name.get('end_datetime') and fields_name.get('end_datetime') >= 0: + if fields_name.get('end_datetime') is not None: end_datetime_index = fields_name.get('end_datetime') end_datetime= res['datas'][index][end_datetime_index] if end_datetime: res['datas'][index][end_datetime_index] = datetime.strftime(end_datetime, "%d/%m/%Y %H:%M") - if fields_name.get('task_id') and fields_name.get('task_id') >= 0: + if fields_name.get('task_id') is not None: taskindex = fields_name.get('task_id') ttask = res['datas'][index][taskindex] if type(ttask) == bool: res['datas'][index][taskindex] = '' - if fields_name.get('start_time') and fields_name.get('start_time') >= 0: + if fields_name.get('start_time') is not None: starttimeindex = fields_name.get('start_time') starttime = float(res['datas'][index][starttimeindex]) if starttime: start_time = tools.format_duration(starttime) res['datas'][index][starttimeindex] = start_time - if fields_name.get('end_time') and fields_name.get('end_time') >= 0: + if fields_name.get('end_time') is not None: endtimeindex = fields_name.get('end_time') endtime = float(res['datas'][index][endtimeindex]) if endtime: end_time = tools.format_duration(endtime) res['datas'][index][endtimeindex] = end_time + if fields_name.get('unit_amount') is not None: + durationindex = fields_name.get('unit_amount') + duration = res['datas'][index][durationindex] and float(res['datas'][index][durationindex]) + if duration: + duration_time = tools.format_duration(duration) + res['datas'][index][durationindex] = duration_time return res @api.model From 88b94fa797761c6ce6ac2ee45ed1465b01e23134 Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Fri, 5 Mar 2021 11:20:06 +0530 Subject: [PATCH 11/11] report list view order changed --- project_report/report/project_timesheet_report_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project_report/report/project_timesheet_report_views.xml b/project_report/report/project_timesheet_report_views.xml index 09ad54b..167c026 100755 --- a/project_report/report/project_timesheet_report_views.xml +++ b/project_report/report/project_timesheet_report_views.xml @@ -10,10 +10,10 @@ + -