diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index d33d9c45722..329c242e0d3 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -98,6 +98,38 @@ class Task(models.Model): timesheet_timer_first_start = fields.Datetime("Timesheet Timer First Use", readonly=True) timesheet_timer_last_stop = fields.Datetime("Timesheet Timer Last Use", readonly=True) display_timesheet_timer = fields.Boolean("Display Timesheet Time", compute='_compute_display_timesheet_timer') + display_timer_start_primary = fields.Boolean(compute='_compute_display_timer_buttons') + display_timer_start_secondary = fields.Boolean(compute='_compute_display_timer_buttons') + display_timer_stop = fields.Boolean(compute='_compute_display_timer_buttons') + display_timer_pause = fields.Boolean(compute='_compute_display_timer_buttons') + display_timer_resume = fields.Boolean(compute='_compute_display_timer_buttons') + + @api.depends('display_timesheet_timer', 'timer_start', 'timer_pause', 'total_hours_spent') + def _compute_display_timer_buttons(self): + for task in self: + start_p, start_s, stop, pause, resume = True, True, True, True, True + if not task.display_timesheet_timer: + start_p, start_s, stop, pause, resume = False, False, False, False, False + else: + if task.timer_start: + start_p, start_s = False, False + if task.timer_pause: + pause = False + else: + resume = False + else: + stop, pause, resume = False, False, False + if not task.total_hours_spent: + start_s = False + else: + start_p = False + task.write({ + 'display_timer_start_primary': start_p, + 'display_timer_start_secondary': start_s, + 'display_timer_stop': stop, + 'display_timer_pause': pause, + 'display_timer_resume': resume, + }) @api.depends('timesheet_ids.unit_amount') def _compute_effective_hours(self): diff --git a/addons/hr_timesheet/views/project_views.xml b/addons/hr_timesheet/views/project_views.xml index 3df4ad3b4b0..a50c6dfb58b 100644 --- a/addons/hr_timesheet/views/project_views.xml +++ b/addons/hr_timesheet/views/project_views.xml @@ -261,16 +261,21 @@ + + + + +