Skip to content

Commit

Permalink
fixup! fixup! [FIX] This fails when the field is being read by a user…
Browse files Browse the repository at this point in the history
… with readonly access because then rec is a hr.employee.public record
  • Loading branch information
thomaspaulb authored and ntsirintanis committed Jun 26, 2023
1 parent 09b9ee3 commit 46d4234
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions project_forecast_line/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46d4234

Please sign in to comment.