From 2745baaf04511acad52e6820a86c2ffd8fb71452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giang=20Pha=CC=A3m?= Date: Fri, 18 Mar 2022 02:35:09 +0000 Subject: [PATCH] [FIX] hr_timesheet, sale_timesheet: Fix project user cannot access Project app If a user has Project/User group but does not have any Timesheets group or Analytic Accounting group, he cannot access the Project app (a security error message appears). The problem is some of 'project.project' model's fields is computing based on 'account.analytic.line' model, which the Project/User group does not have the right to read it. This PR adds corresponding groups to these computed fields, or changing the computing method to make sure there is no error if project user reads on the 'project.project' model. closes odoo/odoo#87393 X-original-commit: 9df63eb25bfe65bce43a557b8635d967fa5a8d6a Signed-off-by: Xavier Signed-off-by: Laurent Stukkens (ltu) --- addons/hr_timesheet/models/project.py | 4 ++-- addons/hr_timesheet/views/project_views.xml | 2 +- addons/sale_timesheet/models/project.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index a794adbdc16..2afc6d6f154 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -38,10 +38,10 @@ class Project(models.Model): ) timesheet_ids = fields.One2many('account.analytic.line', 'project_id', 'Associated Timesheets') - timesheet_count = fields.Integer(compute="_compute_timesheet_count") + timesheet_count = fields.Integer(compute="_compute_timesheet_count", groups='hr_timesheet.group_hr_timesheet_user') timesheet_encode_uom_id = fields.Many2one('uom.uom', related='company_id.timesheet_encode_uom_id') total_timesheet_time = fields.Integer( - compute='_compute_total_timesheet_time', + compute='_compute_total_timesheet_time', groups='hr_timesheet.group_hr_timesheet_user', help="Total number of time (in the proper UoM) recorded in the project, rounded to the unit.") encode_uom_in_days = fields.Boolean(compute='_compute_encode_uom_in_days') is_internal_project = fields.Boolean(compute='_compute_is_internal_project', search='_search_is_internal_project') diff --git a/addons/hr_timesheet/views/project_views.xml b/addons/hr_timesheet/views/project_views.xml index cdd057d1f73..7fd3577dc36 100644 --- a/addons/hr_timesheet/views/project_views.xml +++ b/addons/hr_timesheet/views/project_views.xml @@ -297,7 +297,7 @@ -
+ diff --git a/addons/sale_timesheet/models/project.py b/addons/sale_timesheet/models/project.py index eb5375f28b1..922fc8e024a 100644 --- a/addons/sale_timesheet/models/project.py +++ b/addons/sale_timesheet/models/project.py @@ -38,7 +38,7 @@ class Project(models.Model): help="Employee/Sale Order Item Mapping:\n Defines to which sales order item an employee's timesheet entry will be linked." "By extension, it defines the rate at which an employee's time on the project is billed.") billable_percentage = fields.Integer( - compute='_compute_billable_percentage', + compute='_compute_billable_percentage', groups='hr_timesheet.group_hr_timesheet_approver', help="% of timesheets that are billable compared to the total number of timesheets linked to the AA of the project, rounded to the unit.") display_create_order = fields.Boolean(compute='_compute_display_create_order') timesheet_product_id = fields.Many2one( @@ -51,7 +51,7 @@ class Project(models.Model): help='Select a Service product with which you would like to bill your time spent on tasks.', compute="_compute_timesheet_product_id", store=True, readonly=False, default=_default_timesheet_product_id) - warning_employee_rate = fields.Boolean(compute='_compute_warning_employee_rate') + warning_employee_rate = fields.Boolean(compute='_compute_warning_employee_rate', compute_sudo=True) partner_id = fields.Many2one( compute='_compute_partner_id', store=True, readonly=False) allocated_hours = fields.Float(compute='_compute_allocated_hours', store=True, readonly=False, copy=False)