diff --git a/bemade_sports_clinic/__manifest__.py b/bemade_sports_clinic/__manifest__.py index cbe37c3..efc84fb 100644 --- a/bemade_sports_clinic/__manifest__.py +++ b/bemade_sports_clinic/__manifest__.py @@ -46,6 +46,7 @@ 'views/sports_clinic_menus.xml', 'views/sports_patient_views.xml', 'views/sports_clinic_portal_views.xml', + 'views/res_partner_views.xml', ], 'demo': ['data/demo/sports_clinic_demo_data.xml'], 'installable': True, diff --git a/bemade_sports_clinic/controllers/team_staff_portal.py b/bemade_sports_clinic/controllers/team_staff_portal.py index ff12259..dcb5ec2 100644 --- a/bemade_sports_clinic/controllers/team_staff_portal.py +++ b/bemade_sports_clinic/controllers/team_staff_portal.py @@ -87,3 +87,19 @@ class TeamStaffPortal(CustomerPortal): 'pager': pgr, 'page_name': 'my_players', }) + + @http.route(route=['/my/players/'], type='http', auth='user', website=True) + def view_player(self, player_id, **kw): + """ Display the active injuries for a given player. """ + player = http.request.env['sports.patient'].browse(player_id) + if not player: + raise UserError(_('This player could not be found.')) + injuries = player.injury_ids.filtered(lambda r: r.stage == 'active') + return http.request.render( + template='bemade_sports_clinic.portal_my_player_injuries', + qcontext={ + 'player': player, + 'injuries': injuries, + 'page_name': 'my_player_injuries', + } + ) \ No newline at end of file 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 75e4d78..743fc0f 100644 --- a/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml +++ b/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml @@ -18,6 +18,7 @@ H3C 3J7 +1 (514) 343-6111 https://www.umontreal.ca + Carabins (Football masculin) @@ -103,6 +104,7 @@ H3G 1M8 https://www.concordia.ca + Stingers (Hockey masculin) @@ -156,6 +158,9 @@ head_coach + + + trainer diff --git a/bemade_sports_clinic/models/patient.py b/bemade_sports_clinic/models/patient.py index 6cdc97a..7ce75ec 100644 --- a/bemade_sports_clinic/models/patient.py +++ b/bemade_sports_clinic/models/patient.py @@ -8,6 +8,7 @@ class Patient(models.Model): _name = 'sports.patient' _description = "Patient at a sports medicine clinic." _inherit = ['mail.thread', 'mail.activity.mixin'] + _order = 'last_name, first_name' first_name = fields.Char(required=True, tracking=True) last_name = fields.Char(required=True, tracking=True) @@ -53,8 +54,13 @@ class Patient(models.Model): stage = fields.Selection( selection=[('no_play', 'Injured'), ('practice_ok', 'Cleared for Practice'), ('healthy', 'Cleared to Play')], compute='_compute_stage') - last_consultation_date = fields.Date() + active_injury_count = fields.Integer(compute='_compute_active_injury_count') + + @api.depends('injury_ids.stage') + def _compute_active_injury_count(self): + for rec in self: + rec.active_injury_count = len(rec.injury_ids.filtered(lambda r: r.stage == 'active')) @api.depends('match_status', 'practice_status') def _compute_stage(self): diff --git a/bemade_sports_clinic/views/res_partner_views.xml b/bemade_sports_clinic/views/res_partner_views.xml new file mode 100644 index 0000000..d341b1f --- /dev/null +++ b/bemade_sports_clinic/views/res_partner_views.xml @@ -0,0 +1,15 @@ + + + + res.partner.view.form.sports.teams + + res.partner + + + + + + + + + \ No newline at end of file diff --git a/bemade_sports_clinic/views/sports_clinic_portal_views.xml b/bemade_sports_clinic/views/sports_clinic_portal_views.xml index e1b490d..670aa2d 100644 --- a/bemade_sports_clinic/views/sports_clinic_portal_views.xml +++ b/bemade_sports_clinic/views/sports_clinic_portal_views.xml @@ -51,33 +51,39 @@ - Name - Injured - Injured Since + Last Name + First Name + Active Injuries Match Status Practice Status Estimated Return Date + Last Consultation Date - - + + + - + - - + + + + + @@ -90,25 +96,31 @@ - Name + Last Name + First Name Teams - Injured - Injured Since + Active Injuries Match Status Practice Status Estimated Return Date + Last Consultation Date - - + + + - + -