[FIX] bemade_sports_clinic: add team access to user

This commit is contained in:
Marc Durepos 2024-09-27 14:33:20 -04:00
parent 82c214b644
commit 705c920b4d
5 changed files with 44 additions and 6 deletions

View file

@ -310,6 +310,7 @@ class Patient(models.Model):
followers, the set of followers should be the set of staff on all teams the
patient is part of."""
for patient in self:
patient = patient.sudo()
current_followers = patient.message_partner_ids
future_followers = patient.team_ids.mapped("staff_ids").mapped("partner_id")
removed_followers = current_followers - future_followers

View file

@ -40,7 +40,7 @@ class User(models.Model):
[
{
"team_id": team.id,
"partner_id": rec.id,
"partner_id": rec.partner_id.id,
"role": "other",
}
for team in added_teams

View file

@ -1,2 +1,3 @@
from . import test_patient
from . import test_rights
from . import test_users

View file

@ -23,7 +23,7 @@ class TestRights(TransactionCase):
Command.set(
cls.env.ref(
"bemade_sports_clinic.group_sports_clinic_admin"
).id,
).ids,
),
],
}
@ -38,14 +38,15 @@ class TestRights(TransactionCase):
Command.set(
cls.env.ref(
"bemade_sports_clinic.group_sports_clinic_treatment_professional"
).id,
).ids,
),
],
}
)
_logger.info(
f"Treatment Pro Groups: {cls.treatment_professional_user.groups_id.name}"
)
# _logger.info(
# f"Treatment Pro Groups: "
# f"{cls.treatment_professional_user.groups_id.mapped('name')}"
# )
def test_treatment_pro_has_access_only_to_staffed_teams(self):
"""A treatment professional should only have access to teams and,

View file

@ -0,0 +1,35 @@
from odoo.tests import TransactionCase, tagged, Form
from odoo import Command
@tagged("-at_install", "post_install")
class TestUsers(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
def test_add_team_access_to_user(self):
user = self.env["res.users"].create(
{
"name": "test",
"login": "test",
"password": "test",
"groups_id": [
Command.set(
self.env.ref(
"bemade_sports_clinic.group_sports_clinic_treatment_professional"
).ids
)
],
}
)
team = self.env["sports.team"].create(
{
"name": "Test",
}
)
self.assertNotIn(user, team.staff_ids.user_ids)
user.write({"accessible_team_ids": [Command.link(team.id)]})
# user._inverse_accessible_team_ids()
self.assertIn(user, team.staff_ids.user_ids)