bemade_sports_clinic: notify team staff of updates
Added two mail.message.subtypes to notify all followers of updates to patient status and changes to injury fields. Added a post-migration script to update all existing followers to subscribe to these new subtypes.
This commit is contained in:
parent
47c8f9261c
commit
bcbb3bda1f
5 changed files with 72 additions and 3 deletions
|
|
@ -18,7 +18,7 @@
|
||||||
#
|
#
|
||||||
{
|
{
|
||||||
'name': 'Sports Clinic Management',
|
'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.',
|
'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
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
'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',
|
||||||
'views/sports_team_views.xml',
|
'views/sports_team_views.xml',
|
||||||
'views/sports_clinic_menus.xml',
|
'views/sports_clinic_menus.xml',
|
||||||
'views/sports_patient_views.xml',
|
'views/sports_patient_views.xml',
|
||||||
|
|
|
||||||
23
bemade_sports_clinic/data/sports_clinic_data.xml
Normal file
23
bemade_sports_clinic/data/sports_clinic_data.xml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="subtype_patient_update" model="mail.message.subtype">
|
||||||
|
<field name="name">Patient File Update</field>
|
||||||
|
<field name="res_model">sports.patient</field>
|
||||||
|
<field name="default" eval="True"/>
|
||||||
|
<field name="description">Patient's file has been updated.</field>
|
||||||
|
<field name="internal" eval="False"/>
|
||||||
|
<field name="sequence" eval="4"/>
|
||||||
|
<field name="hidden" eval="False"/>
|
||||||
|
</record>
|
||||||
|
<record id="subtype_patient_injury_update" model="mail.message.subtype">
|
||||||
|
<field name="name">Patient Injury Status Update</field>
|
||||||
|
<field name="res_model">sports.patient.injury</field>
|
||||||
|
<field name="default" eval="True"/>
|
||||||
|
<field name="description">Patient's injury was updated.</field>
|
||||||
|
<field name="internal" eval="False"/>
|
||||||
|
<field name="sequence" eval="4"/>
|
||||||
|
<field name="hidden" eval="False"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
21
bemade_sports_clinic/migrations/16.0.1.5.4/post-migrate.py
Normal file
21
bemade_sports_clinic/migrations/16.0.1.5.4/post-migrate.py
Normal file
|
|
@ -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)]
|
||||||
|
})
|
||||||
|
|
@ -63,7 +63,7 @@ class Patient(models.Model):
|
||||||
stage = fields.Selection(
|
stage = fields.Selection(
|
||||||
selection=[('no_play', 'Injured'), ('practice_ok', 'Practice OK'), ('healthy', 'Play OK')],
|
selection=[('no_play', 'Injured'), ('practice_ok', 'Practice OK'), ('healthy', 'Play OK')],
|
||||||
compute='_compute_stage')
|
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')
|
active_injury_count = fields.Integer(compute='_compute_active_injury_count')
|
||||||
allergies = fields.Text()
|
allergies = fields.Text()
|
||||||
team_info_notes = fields.Html(string="Notes")
|
team_info_notes = fields.Html(string="Notes")
|
||||||
|
|
@ -187,6 +187,22 @@ class Patient(models.Model):
|
||||||
raise_exception=False
|
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):
|
class PatientContact(models.Model):
|
||||||
_name = 'sports.patient.contact'
|
_name = 'sports.patient.contact'
|
||||||
|
|
@ -300,3 +316,11 @@ class PatientInjury(models.Model):
|
||||||
'res_id': self.id,
|
'res_id': self.id,
|
||||||
'context': self._context,
|
'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')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue