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: