From b5ba78382b971bea753766cbe8a7d428336b5c5d Mon Sep 17 00:00:00 2001 From: "pawan.sharma" Date: Thu, 18 Feb 2021 10:13:26 -0800 Subject: [PATCH] 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"> - + +