bemade_sports_clinic: fix index out of bounds error in patient.py

This commit is contained in:
Marc Durepos 2023-11-06 19:48:39 -05:00
parent 59b0e2b099
commit 33cf931299

View file

@ -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: