diff --git a/bemade_sports_clinic/__manifest__.py b/bemade_sports_clinic/__manifest__.py
index 5509180..abf3746 100644
--- a/bemade_sports_clinic/__manifest__.py
+++ b/bemade_sports_clinic/__manifest__.py
@@ -18,7 +18,7 @@
#
{
'name': 'Sports Clinic Management',
- 'version': '16.0.1.5.3',
+ 'version': '16.0.1.5.4',
'summary': 'Manage the patients of a sports medicine clinic.',
'description': """
Adds the notion of sports teams, players (patients), coaches and treatment
@@ -42,6 +42,7 @@
'security/sports_clinic_groups.xml',
'security/ir.model.access.csv',
'security/sports_clinic_rules.xml',
+ 'data/sports_clinic_data.xml',
'views/sports_team_views.xml',
'views/sports_clinic_menus.xml',
'views/sports_patient_views.xml',
diff --git a/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml b/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml
index c148dea..2b1dd30 100644
--- a/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml
+++ b/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml
@@ -186,4 +186,4 @@
-
\ No newline at end of file
+
diff --git a/bemade_sports_clinic/data/sports_clinic_data.xml b/bemade_sports_clinic/data/sports_clinic_data.xml
new file mode 100644
index 0000000..af83b45
--- /dev/null
+++ b/bemade_sports_clinic/data/sports_clinic_data.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ Patient File Update
+ sports.patient
+
+ Patient's file has been updated.
+
+
+
+
+
+ Patient Injury Status Update
+ sports.patient.injury
+
+ Patient's injury was updated.
+
+
+
+
+
+
diff --git a/bemade_sports_clinic/migrations/16.0.1.5.4/post-migrate.py b/bemade_sports_clinic/migrations/16.0.1.5.4/post-migrate.py
new file mode 100644
index 0000000..2323c5d
--- /dev/null
+++ b/bemade_sports_clinic/migrations/16.0.1.5.4/post-migrate.py
@@ -0,0 +1,21 @@
+from odoo import api, SUPERUSER_ID, Command
+
+def migrate(cr, version):
+ env = api.Environment(cr, SUPERUSER_ID, {})
+ patient_followers = env['mail.followers'].search([('res_model', '=',
+ 'sports.patient')])
+ injury_followers = env['mail.followers'].search([('res_model', '=',
+ 'sports.patient.injury')])
+ for f in patient_followers:
+ f.write(
+ {
+ 'subtype_ids':
+ [Command.link(env.ref('bemade_sports_clinic.subtype_patient_update').id)]
+ }
+ )
+ for f in injury_followers:
+ f.write(
+ {
+ 'subtype_ids':
+ [Command.link(env.ref('bemade_sports_clinic.subtype_patient_injury_update').id)]
+ })
diff --git a/bemade_sports_clinic/models/patient.py b/bemade_sports_clinic/models/patient.py
index b1b1e41..7e70019 100644
--- a/bemade_sports_clinic/models/patient.py
+++ b/bemade_sports_clinic/models/patient.py
@@ -63,7 +63,7 @@ class Patient(models.Model):
stage = fields.Selection(
selection=[('no_play', 'Injured'), ('practice_ok', 'Practice OK'), ('healthy', 'Play OK')],
compute='_compute_stage')
- last_consultation_date = fields.Date()
+ last_consultation_date = fields.Date(tracking=True)
active_injury_count = fields.Integer(compute='_compute_active_injury_count')
allergies = fields.Text()
team_info_notes = fields.Html(string="Notes")
@@ -187,6 +187,22 @@ class Patient(models.Model):
raise_exception=False
)
+ def _track_subtype(self, init_values):
+ # List of fields that should result in team staff notification
+ external_values = [
+ "last_consultation_date",
+ "match_status",
+ "practice_status",
+ "predicted_return_date",
+ "return_date",
+ "external_notes",
+ ]
+ if any([v in init_values for v in external_values]):
+ return self.env.ref("bemade_sports_clinic.subtype_patient_update")
+ else:
+ return self.env.ref('mail.mt_note')
+
+
class PatientContact(models.Model):
_name = 'sports.patient.contact'
@@ -300,3 +316,11 @@ class PatientInjury(models.Model):
'res_id': self.id,
'context': self._context,
}
+
+ def _track_subtype(self, init_values):
+ if 'treatment_professional_ids' in init_values \
+ and len(init_values) == 1:
+ return self.env.ref('mail.mt_note')
+ else:
+ return self.env.ref('bemade_sports_clinic.subtype_patient_injury_update')
+