From 9d29c6e4cf3ade656905ba205e3ba2dbc95152eb Mon Sep 17 00:00:00 2001 From: Tom Blauwendraat Date: Wed, 14 Dec 2022 20:09:40 +0100 Subject: [PATCH] fixup! fixup! [FIX] This fails when the field is being read by a user with readonly access because then rec is a hr.employee.public record --- project_forecast_line/models/hr_employee.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/project_forecast_line/models/hr_employee.py b/project_forecast_line/models/hr_employee.py index 2d9ef31554..451338ccd9 100644 --- a/project_forecast_line/models/hr_employee.py +++ b/project_forecast_line/models/hr_employee.py @@ -17,16 +17,14 @@ class HrEmployee(models.Model): role_ids = fields.One2many("hr.employee.forecast.role", "employee_id") main_role_id = fields.Many2one( - "forecast.role", compute="_compute_main_role_id", ondelete="restrict" + "forecast.role", compute="_compute_main_role_id", ondelete="restrict", + compute_sudo=True ) def _compute_main_role_id(self): # can"t store as it depends on current date today = fields.Date.context_today(self) for rec in self: - if not hasattr(rec, "role_ids"): - rec.main_role_id = None - continue rec.main_role_id = rec.role_ids.filtered( lambda r: r.date_start <= today and not r.date_end