From dca23eed4697d43420f372751a980310518db9d1 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Wed, 7 Apr 2021 10:32:47 +0530 Subject: [PATCH 1/6] sort hours within date --- project_report/report/project_timesheet_report.py | 2 +- project_report/static/src/js/graph_renderer.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/project_report/report/project_timesheet_report.py b/project_report/report/project_timesheet_report.py index 10623da..b59bea0 100755 --- a/project_report/report/project_timesheet_report.py +++ b/project_report/report/project_timesheet_report.py @@ -9,7 +9,7 @@ class ProjectTimelineReport(models.Model): _name = "project.timesheet.report" _description = "Project Timesheet Report" - _order = 'start_date desc, project_id desc' + _order = 'start_date desc, duration desc' _auto = False start_date = fields.Date(string='Start Time', readonly=True) diff --git a/project_report/static/src/js/graph_renderer.js b/project_report/static/src/js/graph_renderer.js index 4cec265..a914d3a 100755 --- a/project_report/static/src/js/graph_renderer.js +++ b/project_report/static/src/js/graph_renderer.js @@ -297,6 +297,8 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class); var label = data.labels[item.index]; var value; var boxColor; + console.log('11111', dataset); + console.log('222222', dataset.originIndex); if (this.state.mode === 'bar') { label = this._relabelling(label, dataset.originIndex); if (this.state.processedGroupBy.length > 1 || this.state.origins.length > 1) { From 1167fc1673637436d767a43819deb066592cff0c Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Wed, 7 Apr 2021 10:53:46 +0530 Subject: [PATCH 2/6] sort hours within date --- cor_custom/models/analytic.py | 2 ++ project_report/report/project_timesheet_report.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index c20d34d..8525e0f 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -13,6 +13,8 @@ import dateutil.parser class AccountAnalyticLine(models.Model): _inherit = 'account.analytic.line' + #_order = 'date desc, id desc' + _order = 'start_datetime desc, unit_amount' @api.depends('project_id', 'employee_id') def name_get(self): diff --git a/project_report/report/project_timesheet_report.py b/project_report/report/project_timesheet_report.py index b59bea0..466d755 100755 --- a/project_report/report/project_timesheet_report.py +++ b/project_report/report/project_timesheet_report.py @@ -9,7 +9,7 @@ class ProjectTimelineReport(models.Model): _name = "project.timesheet.report" _description = "Project Timesheet Report" - _order = 'start_date desc, duration desc' + _order = 'start_date desc, duration desc, project_id desc' _auto = False start_date = fields.Date(string='Start Time', readonly=True) From ee6e83a30b70abee6ea806faf26d4498971df381 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Wed, 7 Apr 2021 11:50:23 +0530 Subject: [PATCH 3/6] update date from datetime --- cor_custom/models/analytic.py | 12 +++++++----- cor_custom/views/analytic_view.xml | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index 8525e0f..564627f 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -14,7 +14,7 @@ import dateutil.parser class AccountAnalyticLine(models.Model): _inherit = 'account.analytic.line' #_order = 'date desc, id desc' - _order = 'start_datetime desc, unit_amount' + _order = 'date desc, unit_amount desc' @api.depends('project_id', 'employee_id') def name_get(self): @@ -39,6 +39,7 @@ class AccountAnalyticLine(models.Model): #end_time = fields.Float(string='End Time', digits=(16, 2)) start_datetime = fields.Datetime("Start Time", required=True) end_datetime = fields.Datetime("End Time", required=True) + date = fields.Date('Date', required=True, index=True, compute='_compute_start_end_date', store=True) unit_amount = fields.Float('Duration', default=0.0) parent_project = fields.Many2one('project.project', related='project_id.parent_project', string='Parent Project') sub_project = fields.Many2one('project.project', domain="[('is_sub_project', '=', True)]", @@ -218,7 +219,8 @@ class AccountAnalyticLine(models.Model): self.project_id._onchange_calculate_timesheet_hours() return res - @api.onchange('start_datetime', 'end_datetime') - def _onchange_start_end_date(self): - if self.start_datetime: - self.date = self.start_datetime.date() + @api.depends('start_datetime', 'end_datetime') + def _compute_start_end_date(self): + for rec in self: + if rec.start_datetime: + rec.date = rec.start_datetime.date() diff --git a/cor_custom/views/analytic_view.xml b/cor_custom/views/analytic_view.xml index df009c5..1cfb025 100755 --- a/cor_custom/views/analytic_view.xml +++ b/cor_custom/views/analytic_view.xml @@ -63,7 +63,7 @@ account.analytic.line - + From fc09e07f350b5074df19cb70c18a290b51c18e1b Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Wed, 7 Apr 2021 11:50:32 +0530 Subject: [PATCH 4/6] update date from datetime --- cor_custom/views/analytic_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cor_custom/views/analytic_view.xml b/cor_custom/views/analytic_view.xml index 1cfb025..df009c5 100755 --- a/cor_custom/views/analytic_view.xml +++ b/cor_custom/views/analytic_view.xml @@ -63,7 +63,7 @@ account.analytic.line - + From 92980f8473b768c542f277a938c617bc0b3dcb85 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Wed, 7 Apr 2021 12:09:52 +0530 Subject: [PATCH 5/6] change desc to asc --- cor_custom/models/analytic.py | 2 +- project_report/report/project_timesheet_report.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index 564627f..f22dfe7 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -14,7 +14,7 @@ import dateutil.parser class AccountAnalyticLine(models.Model): _inherit = 'account.analytic.line' #_order = 'date desc, id desc' - _order = 'date desc, unit_amount desc' + _order = 'date desc, unit_amount' @api.depends('project_id', 'employee_id') def name_get(self): diff --git a/project_report/report/project_timesheet_report.py b/project_report/report/project_timesheet_report.py index 466d755..583cc9f 100755 --- a/project_report/report/project_timesheet_report.py +++ b/project_report/report/project_timesheet_report.py @@ -9,7 +9,7 @@ class ProjectTimelineReport(models.Model): _name = "project.timesheet.report" _description = "Project Timesheet Report" - _order = 'start_date desc, duration desc, project_id desc' + _order = 'start_date desc, duration, project_id desc' _auto = False start_date = fields.Date(string='Start Time', readonly=True) From 3a7625a6aa490771ffcafb3a9bcf1e3f5b0e9a9c Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Wed, 7 Apr 2021 14:12:18 +0530 Subject: [PATCH 6/6] Report project inactive hidden --- project_report/report/project_timesheet_report.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/project_report/report/project_timesheet_report.py b/project_report/report/project_timesheet_report.py index 583cc9f..6a551fb 100755 --- a/project_report/report/project_timesheet_report.py +++ b/project_report/report/project_timesheet_report.py @@ -70,17 +70,20 @@ class ProjectTimelineReport(models.Model): CREATE OR REPLACE VIEW %s AS ( SELECT ROW_NUMBER() OVER() as id, - start_datetime::date as start_date, - employee_id, - project_id, - sub_project, + aal.start_datetime::date as start_date, + aal.employee_id, + aal.project_id, + aal.sub_project, unit_amount as duration, CONCAT(to_char((start_datetime at time zone 'utc') at time zone 'Asia/Jerusalem', 'HH24:MI'), '-', to_char((end_datetime at time zone 'utc') at time zone 'Asia/Jerusalem', 'HH24:MI')) as timestamp, --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 + aal.name as description + from account_analytic_line aal + left join project_project pro on pro.id = aal.project_id + --left join hr_employee emp on emp.id = aal.employee_id + where pro.active = True )""" % (self._table,))