From 2e2cd56db32fe00cde59c0c153b473456b6db467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Thu, 24 Aug 2017 12:02:05 +0200 Subject: [PATCH] [IMP] hr_timesheet: hide timesheet stuff according to user groups You should be timesheet user to see 'Timesheet' tab on task form view, and the project overview (on kanban project). --- addons/hr_timesheet/models/project.py | 3 ++- addons/hr_timesheet/views/project_views.xml | 11 +++++------ addons/sale_timesheet/views/project_task_views.xml | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index 8a559139e59..4202e49bc45 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -10,6 +10,7 @@ class Project(models.Model): allow_timesheets = fields.Boolean("Allow timesheets", default=True) + class Task(models.Model): _inherit = "project.task" @@ -25,7 +26,7 @@ class Task(models.Model): children_hours += max(child_task.planned_hours, child_task.effective_hours + child_task.children_hours) task.children_hours = children_hours - task.effective_hours = sum(task.timesheet_ids.mapped('unit_amount')) + task.effective_hours = sum(task.sudo().timesheet_ids.mapped('unit_amount')) # use 'sudo' here to allow project user (without timesheet user right) to create task task.remaining_hours = task.planned_hours - task.effective_hours - task.children_hours task.total_hours = max(task.planned_hours, task.effective_hours) task.total_hours_spent = task.effective_hours + task.children_hours diff --git a/addons/hr_timesheet/views/project_views.xml b/addons/hr_timesheet/views/project_views.xml index 4b3bf9ad4b0..50afd40a4d1 100644 --- a/addons/hr_timesheet/views/project_views.xml +++ b/addons/hr_timesheet/views/project_views.xml @@ -40,7 +40,7 @@ 24
@@ -55,11 +55,10 @@ project.task.form.inherited project.task - + - - + @@ -119,12 +118,12 @@ -