Skip to content

Commit

Permalink
[FIX] hr_school: compute field avoid permissions (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
oihane authored Dec 3, 2021
1 parent dc30770 commit b561306
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hr_school/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ class ResPartner(models.Model):
comodel_name='hr.employee.supervised.year',
inverse_name='student_id', string='Tutors per year')
current_year_tutor_ids = fields.Many2many(
comodel_name="hr.employee", compute="_compute_current_year_tutor_ids",
string="Current Tutors")
comodel_name="hr.employee",
compute="_compute_current_year_tutor_ids",
string="Current Tutors",
compute_sudo=True)
allowed_user_ids = fields.Many2many(
comodel_name='res.users', relation='rel_res_partner_users',
column1='partner_id', column2='user_id', string='Allowed users',
Expand All @@ -20,8 +22,8 @@ class ResPartner(models.Model):

@api.depends("year_tutor_ids")
def _compute_current_year_tutor_ids(self):
for partner in self.filtered("year_tutor_ids"):
tutors = partner.year_tutor_ids.filtered(
for partner in self:
tutors = partner.sudo().year_tutor_ids.filtered(
lambda t: t.school_year_id.current)
partner.current_year_tutor_ids = tutors.mapped("teacher_id")

Expand Down

0 comments on commit b561306

Please sign in to comment.