From 33cf9312993e474ab32ca96fdf8de500579a13be Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Mon, 6 Nov 2023 19:48:39 -0500 Subject: [PATCH] bemade_sports_clinic: fix index out of bounds error in patient.py --- bemade_sports_clinic/models/patient.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bemade_sports_clinic/models/patient.py b/bemade_sports_clinic/models/patient.py index 7ce75ec..1073ad6 100644 --- a/bemade_sports_clinic/models/patient.py +++ b/bemade_sports_clinic/models/patient.py @@ -92,7 +92,7 @@ class Patient(models.Model): rec.is_injured = rec.practice_status != 'yes' or rec.match_status != 'yes' if rec.is_injured: rec.injured_since = \ - rec.injury_ids.filtered(lambda r: not r.stage == 'resolved').sorted( + rec.injury_ids and rec.injury_ids.filtered(lambda r: not r.stage == 'resolved').sorted( 'injury_date_time')[0].injury_date_time else: rec.injured_since = False @@ -169,8 +169,6 @@ class PatientInjury(models.Model): if rec.stage == 'resolved' and not rec.resolution_date: raise ValidationError(_('Cannot set an injury as resolved without setting the resolution date first.')) - - def write(self, vals): super().write(vals) if 'treatment_professional_ids' in vals: