updates for followers
This commit is contained in:
parent
eda7f32c7a
commit
c9690d46b1
4 changed files with 60 additions and 26 deletions
|
|
@ -17,10 +17,10 @@
|
||||||
# DEALINGS IN THE SOFTWARE.
|
# DEALINGS IN THE SOFTWARE.
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
'name': 'Sports Clinic Management',
|
"name": "Sports Clinic Management",
|
||||||
'version': '16.0.1.5.10',
|
"version": "16.0.1.6.0",
|
||||||
'summary': 'Manage the patients of a sports medicine clinic.',
|
"summary": "Manage the patients of a sports medicine clinic.",
|
||||||
'description': """
|
"description": """
|
||||||
Adds the notion of sports teams, players (patients), coaches and treatment
|
Adds the notion of sports teams, players (patients), coaches and treatment
|
||||||
professionals. The core purpose of this module is to keep track of the treatment
|
professionals. The core purpose of this module is to keep track of the treatment
|
||||||
history of players and to make it appropriately accessible to the various
|
history of players and to make it appropriately accessible to the various
|
||||||
|
|
@ -33,26 +33,26 @@
|
||||||
External users (portal users) can be added to give coaches and other team
|
External users (portal users) can be added to give coaches and other team
|
||||||
personnel access to limited player data such as estimated return-to-play dates.
|
personnel access to limited player data such as estimated return-to-play dates.
|
||||||
""",
|
""",
|
||||||
'category': 'Services/Medical',
|
"category": "Services/Medical",
|
||||||
'author': 'Bemade Inc.',
|
"author": "Bemade Inc.",
|
||||||
'website': 'https://www.bemade.org',
|
"website": "https://www.bemade.org",
|
||||||
'license': 'OPL-1',
|
"license": "OPL-1",
|
||||||
'depends': ['portal', 'contacts'],
|
"depends": ["portal", "contacts"],
|
||||||
'data': [
|
"data": [
|
||||||
'security/sports_clinic_groups.xml',
|
"security/sports_clinic_groups.xml",
|
||||||
'security/ir.model.access.csv',
|
"security/ir.model.access.csv",
|
||||||
'security/sports_clinic_rules.xml',
|
"security/sports_clinic_rules.xml",
|
||||||
'data/sports_clinic_data.xml',
|
"data/sports_clinic_data.xml",
|
||||||
'views/sports_team_views.xml',
|
"views/sports_team_views.xml",
|
||||||
'views/sports_clinic_menus.xml',
|
"views/sports_clinic_menus.xml",
|
||||||
'views/sports_patient_injury_views.xml',
|
"views/sports_patient_injury_views.xml",
|
||||||
'views/sports_patient_views.xml',
|
"views/sports_patient_views.xml",
|
||||||
'views/sports_clinic_portal_views.xml',
|
"views/sports_clinic_portal_views.xml",
|
||||||
'views/res_partner_views.xml',
|
"views/res_partner_views.xml",
|
||||||
'views/res_users_views.xml',
|
"views/res_users_views.xml",
|
||||||
],
|
],
|
||||||
'demo': ['data/demo/sports_clinic_demo_data.xml'],
|
"demo": ["data/demo/sports_clinic_demo_data.xml"],
|
||||||
'installable': True,
|
"installable": True,
|
||||||
'auto_install': False,
|
"auto_install": False,
|
||||||
'application': True,
|
"application": True,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(cr, version):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
env["sports.patient"].search([]).recompute_followers()
|
||||||
|
|
@ -35,7 +35,11 @@ class PatientInjury(models.Model):
|
||||||
# TODO: Add field consentement_parental = fields.Selection(oui, non, non-applicable)
|
# TODO: Add field consentement_parental = fields.Selection(oui, non, non-applicable)
|
||||||
|
|
||||||
patient_id = fields.Many2one(
|
patient_id = fields.Many2one(
|
||||||
comodel_name="sports.patient", string="Patient", readonly=True, required=True
|
comodel_name="sports.patient",
|
||||||
|
string="Patient",
|
||||||
|
readonly=True,
|
||||||
|
required=True,
|
||||||
|
ondelete="cascade",
|
||||||
)
|
)
|
||||||
patient_name = fields.Char(related="patient_id.name")
|
patient_name = fields.Char(related="patient_id.name")
|
||||||
diagnosis = fields.Char(tracking=True)
|
diagnosis = fields.Char(tracking=True)
|
||||||
|
|
|
||||||
|
|
@ -143,15 +143,39 @@ class TestPatient(TransactionCase):
|
||||||
self.assertIn(cp_id, injury.message_partner_ids)
|
self.assertIn(cp_id, injury.message_partner_ids)
|
||||||
|
|
||||||
def test_removing_second_team_correctly_adjusts_staff(self):
|
def test_removing_second_team_correctly_adjusts_staff(self):
|
||||||
|
"""Tests both removing from the team side and from the patient side."""
|
||||||
team2, therapist, coach = self._generate_second_team_and_staff()
|
team2, therapist, coach = self._generate_second_team_and_staff()
|
||||||
self.patient1.write({"team_ids": [Command.link(team2.id)]})
|
self.patient1.write({"team_ids": [Command.link(team2.id)]})
|
||||||
self.assertIn(self.patient1, team2.patient_ids)
|
self.assertIn(self.patient1, team2.patient_ids)
|
||||||
self.assertIn(therapist, self.patient1.message_partner_ids)
|
self.assertIn(therapist, self.patient1.message_partner_ids)
|
||||||
|
|
||||||
team2.write({"patient_ids": [Command.unlink(self.patient1.id)]})
|
team2.write({"patient_ids": [Command.unlink(self.patient1.id)]})
|
||||||
|
|
||||||
self.assertNotIn(self.patient1, team2.patient_ids)
|
self.assertNotIn(self.patient1, team2.patient_ids)
|
||||||
self.assertEqual(self.patient1.message_partner_ids, coach)
|
self.assertEqual(self.patient1.message_partner_ids, coach)
|
||||||
self.assertEqual(self.patient1_injury.message_partner_ids, coach)
|
self.assertEqual(self.patient1_injury.message_partner_ids, coach)
|
||||||
|
|
||||||
|
self.patient1.write({"team_ids": [Command.link(team2.id)]})
|
||||||
|
|
||||||
|
self.assertIn(self.patient1, team2.patient_ids)
|
||||||
|
self.assertIn(therapist, self.patient1.message_partner_ids)
|
||||||
|
|
||||||
|
self.patient1.write({"team_ids": [Command.unlink(team2.id)]})
|
||||||
|
|
||||||
|
self.assertNotIn(self.patient1, team2.patient_ids)
|
||||||
|
self.assertEqual(self.patient1.message_partner_ids, coach)
|
||||||
|
self.assertEqual(self.patient1_injury.message_partner_ids, coach)
|
||||||
|
|
||||||
|
def test_adding_patient_injury_sets_followers(self):
|
||||||
|
injury2 = self.env["sports.patient.injury"].create(
|
||||||
|
{
|
||||||
|
"patient_id": self.patient1.id,
|
||||||
|
"diagnosis": "some other injury",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(injury2.message_partner_ids, self.coach.partner_id)
|
||||||
|
|
||||||
def _generate_second_team_and_staff(self):
|
def _generate_second_team_and_staff(self):
|
||||||
team2 = self.env["sports.team"].create(
|
team2 = self.env["sports.team"].create(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue