From fe339788791cee74ab127fd85ce3203c2c576873 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 18:15:13 +0530 Subject: [PATCH 1/9] add time diff between two datetimes --- cor_custom/models/analytic.py | 24 +++++++++++++++++------- cor_custom/views/analytic_view.xml | 8 ++++---- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index 1dd460b..a449304 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -26,8 +26,8 @@ class AccountAnalyticLine(models.Model): def _default_end_datetime(self): return fields.Datetime.to_string(datetime.combine(fields.Datetime.now(), datetime.max.time())) - start_datetime = fields.Datetime("Start Time", required=True, default=_default_start_datetime) - end_datetime = fields.Datetime("End Time", required=True, default=_default_end_datetime) + start_datetime = fields.Datetime("Start Time", required=True) + end_datetime = fields.Datetime("End Time", required=True) @api.onchange('project_id') @@ -104,17 +104,27 @@ class AccountAnalyticLine(models.Model): if rec.end_time < rec.start_time: raise exceptions.ValidationError(_('End time cannot be earlier than Start time')) - @api.onchange('start_time', 'end_time', 'start_datetime', 'end_datetime') + @api.onchange('start_time', 'end_time') def _onchange_start_end_time(self): if self.start_time > 0 and self.end_time > 0: res = self.end_time - self.start_time if res <= 0: raise ValidationError(_("End time cannot be earlier than Start time")) self.unit_amount = res - # if self.start_datetime and self.end_datetime: - # res1 = self.end_datetime - self.start_datetime - # print('ressssssssss', res1) - # self.unit_amount = res1 + + @api.onchange('start_datetime', 'end_datetime') + def _onchange_start_end_date_time(self): + if self.start_datetime and self.end_datetime: + total_hours = (self.end_datetime - self.start_datetime).total_seconds() / 3600 + self.unit_amount = total_hours + + # @api.onchange('start_time', 'end_time') + # def _onchange_start_end_time(self): + # if self.start_time > 0: + # dt = datetime.strptime('26 Sep 2012', '%d %b %Y') + # print('HHHHHHHH', dt) + # newdatetime = dt.replace(hour=11, minute=59) + # print('GGGGGGGGGGGGG', newdatetime) @api.model def export_data(self, fields): diff --git a/cor_custom/views/analytic_view.xml b/cor_custom/views/analytic_view.xml index a867918..6164ace 100755 --- a/cor_custom/views/analytic_view.xml +++ b/cor_custom/views/analytic_view.xml @@ -73,8 +73,8 @@ widget="task_with_hours" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/> - - + + - - + + From d76434022efada6e1f6b23cda5ef8a5f92ef3e97 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 19:13:42 +0530 Subject: [PATCH 2/9] hide start and end time --- cor_custom/views/analytic_view.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cor_custom/views/analytic_view.xml b/cor_custom/views/analytic_view.xml index 6164ace..c6c60c7 100755 --- a/cor_custom/views/analytic_view.xml +++ b/cor_custom/views/analytic_view.xml @@ -73,8 +73,8 @@ widget="task_with_hours" context="{'default_project_id': project_id}" domain="[('project_id', '=', project_id)]"/> - - + + - - + + @@ -192,7 +192,8 @@ form_view_id="%(hr_timesheet.hr_timesheet_line_form)d" event_open_popup="true" quick_add="False"> - + + From a7e1e5149694b9e1cc55ad18280692ba31116fd7 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 20:09:48 +0530 Subject: [PATCH 3/9] add project manager in view allocation --- cor_custom/models/project_hours.py | 1 + cor_custom/views/project_hours_view.xml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/cor_custom/models/project_hours.py b/cor_custom/models/project_hours.py index 6f88ee3..9604fb3 100755 --- a/cor_custom/models/project_hours.py +++ b/cor_custom/models/project_hours.py @@ -15,6 +15,7 @@ class ProjectConsultantHrs(models.Model): _order = 'employee_id, end_date desc' project_id = fields.Many2one('project.project', string="Project", required=True) + user_id = fields.Many2one('res.user', related='project_id.user_id') employee_id = fields.Many2one('hr.employee', string="Consultant", required=True) start_date = fields.Date('Start Date', required=True) end_date = fields.Date('End Date', required=True) diff --git a/cor_custom/views/project_hours_view.xml b/cor_custom/views/project_hours_view.xml index ff44311..575441c 100755 --- a/cor_custom/views/project_hours_view.xml +++ b/cor_custom/views/project_hours_view.xml @@ -8,6 +8,7 @@
+ @@ -26,6 +27,7 @@ + From 66bf8188a4193d46deca3ed6048158873910ff0f Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 20:19:08 +0530 Subject: [PATCH 4/9] add project manager in view allocation --- cor_custom/models/project_hours.py | 1 - cor_custom/report/project_hours_report.py | 1 + cor_custom/report/project_hours_report_view.xml | 2 ++ cor_custom/views/project_hours_view.xml | 2 -- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cor_custom/models/project_hours.py b/cor_custom/models/project_hours.py index 9604fb3..6f88ee3 100755 --- a/cor_custom/models/project_hours.py +++ b/cor_custom/models/project_hours.py @@ -15,7 +15,6 @@ class ProjectConsultantHrs(models.Model): _order = 'employee_id, end_date desc' project_id = fields.Many2one('project.project', string="Project", required=True) - user_id = fields.Many2one('res.user', related='project_id.user_id') employee_id = fields.Many2one('hr.employee', string="Consultant", required=True) start_date = fields.Date('Start Date', required=True) end_date = fields.Date('End Date', required=True) diff --git a/cor_custom/report/project_hours_report.py b/cor_custom/report/project_hours_report.py index b347d84..22add7e 100755 --- a/cor_custom/report/project_hours_report.py +++ b/cor_custom/report/project_hours_report.py @@ -13,6 +13,7 @@ class BudgetHrsAnalysis(models.Model): _auto = False project_id = fields.Many2one('project.project', string='Project', readonly=True) + user_id = fields.Many2one('res.user', related='project_id.user_id') employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) start_date = fields.Date(string='Start Date', readonly=True) end_date = fields.Date(string='End Date', readonly=True) diff --git a/cor_custom/report/project_hours_report_view.xml b/cor_custom/report/project_hours_report_view.xml index cce1b1b..c6f91f1 100755 --- a/cor_custom/report/project_hours_report_view.xml +++ b/cor_custom/report/project_hours_report_view.xml @@ -8,6 +8,7 @@ + @@ -25,6 +26,7 @@ + diff --git a/cor_custom/views/project_hours_view.xml b/cor_custom/views/project_hours_view.xml index 575441c..ff44311 100755 --- a/cor_custom/views/project_hours_view.xml +++ b/cor_custom/views/project_hours_view.xml @@ -8,7 +8,6 @@ - @@ -27,7 +26,6 @@ - From f04408b5ec90d7fffb2df80397825d533ffecdc5 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 20:26:55 +0530 Subject: [PATCH 5/9] table changes --- cor_custom/report/project_hours_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cor_custom/report/project_hours_report.py b/cor_custom/report/project_hours_report.py index 22add7e..2d9a23e 100755 --- a/cor_custom/report/project_hours_report.py +++ b/cor_custom/report/project_hours_report.py @@ -13,7 +13,7 @@ class BudgetHrsAnalysis(models.Model): _auto = False project_id = fields.Many2one('project.project', string='Project', readonly=True) - user_id = fields.Many2one('res.user', related='project_id.user_id') + user_id = fields.Many2one('res.users', related='project_id.user_id') employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) start_date = fields.Date(string='Start Date', readonly=True) end_date = fields.Date(string='End Date', readonly=True) From 98a135d612d9df1c47f82a984f9dce404294374f Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 20:35:42 +0530 Subject: [PATCH 6/9] manager table store true --- cor_custom/report/project_hours_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cor_custom/report/project_hours_report.py b/cor_custom/report/project_hours_report.py index 2d9a23e..69d9844 100755 --- a/cor_custom/report/project_hours_report.py +++ b/cor_custom/report/project_hours_report.py @@ -13,7 +13,7 @@ class BudgetHrsAnalysis(models.Model): _auto = False project_id = fields.Many2one('project.project', string='Project', readonly=True) - user_id = fields.Many2one('res.users', related='project_id.user_id') + user_id = fields.Many2one('res.users', related='project_id.user_id', store=True) employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) start_date = fields.Date(string='Start Date', readonly=True) end_date = fields.Date(string='End Date', readonly=True) From 1f53a2712d387c8e9bdb7299a0cdb1011621af91 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 23:37:36 +0530 Subject: [PATCH 7/9] remove extra code --- cor_custom/models/analytic.py | 24 ++++++------------- cor_custom/report/project_hours_report.py | 1 - .../report/project_hours_report_view.xml | 4 +--- cor_custom/views/analytic_view.xml | 3 +-- 4 files changed, 9 insertions(+), 23 deletions(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index a142200..d67c93c 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -26,8 +26,8 @@ class AccountAnalyticLine(models.Model): def _default_end_datetime(self): return fields.Datetime.to_string(datetime.combine(fields.Datetime.now(), datetime.max.time())) - start_datetime = fields.Datetime("Start Time", required=True) - end_datetime = fields.Datetime("End Time", required=True) + start_datetime = fields.Datetime("Start Time", required=True, default=_default_start_datetime) + end_datetime = fields.Datetime("End Time", required=True, default=_default_end_datetime) @api.onchange('project_id') @@ -104,27 +104,17 @@ class AccountAnalyticLine(models.Model): if rec.end_time < rec.start_time: raise exceptions.ValidationError(_('End time cannot be earlier than Start time')) - @api.onchange('start_time', 'end_time') + @api.onchange('start_time', 'end_time', 'start_datetime', 'end_datetime') def _onchange_start_end_time(self): if self.start_time > 0 and self.end_time > 0: res = self.end_time - self.start_time if res <= 0: raise ValidationError(_("End time cannot be earlier than Start time")) self.unit_amount = res - - @api.onchange('start_datetime', 'end_datetime') - def _onchange_start_end_date_time(self): - if self.start_datetime and self.end_datetime: - total_hours = (self.end_datetime - self.start_datetime).total_seconds() / 3600 - self.unit_amount = total_hours - - # @api.onchange('start_time', 'end_time') - # def _onchange_start_end_time(self): - # if self.start_time > 0: - # dt = datetime.strptime('26 Sep 2012', '%d %b %Y') - # print('HHHHHHHH', dt) - # newdatetime = dt.replace(hour=11, minute=59) - # print('GGGGGGGGGGGGG', newdatetime) + # if self.start_datetime and self.end_datetime: + # res1 = self.end_datetime - self.start_datetime + # print('ressssssssss', res1) + # self.unit_amount = res1 @api.model def export_data(self, fields): diff --git a/cor_custom/report/project_hours_report.py b/cor_custom/report/project_hours_report.py index 69d9844..b347d84 100755 --- a/cor_custom/report/project_hours_report.py +++ b/cor_custom/report/project_hours_report.py @@ -13,7 +13,6 @@ class BudgetHrsAnalysis(models.Model): _auto = False project_id = fields.Many2one('project.project', string='Project', readonly=True) - user_id = fields.Many2one('res.users', related='project_id.user_id', store=True) employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) start_date = fields.Date(string='Start Date', readonly=True) end_date = fields.Date(string='End Date', readonly=True) diff --git a/cor_custom/report/project_hours_report_view.xml b/cor_custom/report/project_hours_report_view.xml index c6f91f1..637c41f 100755 --- a/cor_custom/report/project_hours_report_view.xml +++ b/cor_custom/report/project_hours_report_view.xml @@ -8,7 +8,6 @@ - @@ -26,7 +25,6 @@ - @@ -86,7 +84,7 @@ Consultant Allocation ir.actions.act_window project.consultant.hrs.report - tree,calendar,graph + tree,form,calendar,graph { 'search_default_project': 1, diff --git a/cor_custom/views/analytic_view.xml b/cor_custom/views/analytic_view.xml index c6c60c7..a867918 100755 --- a/cor_custom/views/analytic_view.xml +++ b/cor_custom/views/analytic_view.xml @@ -192,8 +192,7 @@ form_view_id="%(hr_timesheet.hr_timesheet_line_form)d" event_open_popup="true" quick_add="False"> - - + From b5ba78382b971bea753766cbe8a7d428336b5c5d Mon Sep 17 00:00:00 2001 From: "pawan.sharma" Date: Thu, 18 Feb 2021 10:13:26 -0800 Subject: [PATCH 8/9] Revert "Merge branch 'pawan_branch' into 'development'" This reverts merge request !125 --- cor_custom/models/analytic.py | 24 +++++++++++++------ cor_custom/report/project_hours_report.py | 1 + .../report/project_hours_report_view.xml | 4 +++- cor_custom/views/analytic_view.xml | 3 ++- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py index d67c93c..a142200 100755 --- a/cor_custom/models/analytic.py +++ b/cor_custom/models/analytic.py @@ -26,8 +26,8 @@ class AccountAnalyticLine(models.Model): def _default_end_datetime(self): return fields.Datetime.to_string(datetime.combine(fields.Datetime.now(), datetime.max.time())) - start_datetime = fields.Datetime("Start Time", required=True, default=_default_start_datetime) - end_datetime = fields.Datetime("End Time", required=True, default=_default_end_datetime) + start_datetime = fields.Datetime("Start Time", required=True) + end_datetime = fields.Datetime("End Time", required=True) @api.onchange('project_id') @@ -104,17 +104,27 @@ class AccountAnalyticLine(models.Model): if rec.end_time < rec.start_time: raise exceptions.ValidationError(_('End time cannot be earlier than Start time')) - @api.onchange('start_time', 'end_time', 'start_datetime', 'end_datetime') + @api.onchange('start_time', 'end_time') def _onchange_start_end_time(self): if self.start_time > 0 and self.end_time > 0: res = self.end_time - self.start_time if res <= 0: raise ValidationError(_("End time cannot be earlier than Start time")) self.unit_amount = res - # if self.start_datetime and self.end_datetime: - # res1 = self.end_datetime - self.start_datetime - # print('ressssssssss', res1) - # self.unit_amount = res1 + + @api.onchange('start_datetime', 'end_datetime') + def _onchange_start_end_date_time(self): + if self.start_datetime and self.end_datetime: + total_hours = (self.end_datetime - self.start_datetime).total_seconds() / 3600 + self.unit_amount = total_hours + + # @api.onchange('start_time', 'end_time') + # def _onchange_start_end_time(self): + # if self.start_time > 0: + # dt = datetime.strptime('26 Sep 2012', '%d %b %Y') + # print('HHHHHHHH', dt) + # newdatetime = dt.replace(hour=11, minute=59) + # print('GGGGGGGGGGGGG', newdatetime) @api.model def export_data(self, fields): diff --git a/cor_custom/report/project_hours_report.py b/cor_custom/report/project_hours_report.py index b347d84..69d9844 100755 --- a/cor_custom/report/project_hours_report.py +++ b/cor_custom/report/project_hours_report.py @@ -13,6 +13,7 @@ class BudgetHrsAnalysis(models.Model): _auto = False project_id = fields.Many2one('project.project', string='Project', readonly=True) + user_id = fields.Many2one('res.users', related='project_id.user_id', store=True) employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) start_date = fields.Date(string='Start Date', readonly=True) end_date = fields.Date(string='End Date', readonly=True) diff --git a/cor_custom/report/project_hours_report_view.xml b/cor_custom/report/project_hours_report_view.xml index 637c41f..c6f91f1 100755 --- a/cor_custom/report/project_hours_report_view.xml +++ b/cor_custom/report/project_hours_report_view.xml @@ -8,6 +8,7 @@ + @@ -25,6 +26,7 @@ + @@ -84,7 +86,7 @@ Consultant Allocation ir.actions.act_window project.consultant.hrs.report - tree,form,calendar,graph + tree,calendar,graph { 'search_default_project': 1, diff --git a/cor_custom/views/analytic_view.xml b/cor_custom/views/analytic_view.xml index a867918..c6c60c7 100755 --- a/cor_custom/views/analytic_view.xml +++ b/cor_custom/views/analytic_view.xml @@ -192,7 +192,8 @@ form_view_id="%(hr_timesheet.hr_timesheet_line_form)d" event_open_popup="true" quick_add="False"> - + + From 19f13ab82dfe2b6a7e92750995a5b333b8dc489d Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Fri, 19 Feb 2021 00:02:06 +0530 Subject: [PATCH 9/9] remove comment --- cor_custom/report/project_hours_report.py | 1 - cor_custom/report/project_hours_report_view.xml | 2 -- 2 files changed, 3 deletions(-) diff --git a/cor_custom/report/project_hours_report.py b/cor_custom/report/project_hours_report.py index 69d9844..b347d84 100755 --- a/cor_custom/report/project_hours_report.py +++ b/cor_custom/report/project_hours_report.py @@ -13,7 +13,6 @@ class BudgetHrsAnalysis(models.Model): _auto = False project_id = fields.Many2one('project.project', string='Project', readonly=True) - user_id = fields.Many2one('res.users', related='project_id.user_id', store=True) employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) start_date = fields.Date(string='Start Date', readonly=True) end_date = fields.Date(string='End Date', readonly=True) diff --git a/cor_custom/report/project_hours_report_view.xml b/cor_custom/report/project_hours_report_view.xml index c6f91f1..cce1b1b 100755 --- a/cor_custom/report/project_hours_report_view.xml +++ b/cor_custom/report/project_hours_report_view.xml @@ -8,7 +8,6 @@ - @@ -26,7 +25,6 @@ -