From 1f53a2712d387c8e9bdb7299a0cdb1011621af91 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Thu, 18 Feb 2021 23:37:36 +0530 Subject: [PATCH] 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"> - - +