Fixed injured player count issue to reflect v16.0 logic of basing injured count on player stage rather than active injuries.

This commit is contained in:
Denis Durepos 2025-08-10 05:47:16 -04:00
parent 5abdebb3a1
commit c135c3eef7

View file

@ -254,6 +254,12 @@ class Patient(models.Model):
@api.depends("practice_status", "match_status", "injury_ids.injury_date") @api.depends("practice_status", "match_status", "injury_ids.injury_date")
def _compute_is_injured(self): def _compute_is_injured(self):
for patient in self: for patient in self:
# Patient is injured if their stage is not "healthy"
patient.is_injured = patient.stage != "healthy"
# For injured_since, find the earliest injury date from active injuries
# This logic is kept but may not be reliable until user habits change
if patient.is_injured:
active_injuries = self.env["sports.patient.injury"].search( active_injuries = self.env["sports.patient.injury"].search(
[ [
("patient_id", "=", patient.id), ("patient_id", "=", patient.id),
@ -261,11 +267,11 @@ class Patient(models.Model):
] ]
) )
if active_injuries: if active_injuries:
patient.is_injured = True
injury_dates = [d for d in active_injuries.mapped("injury_date") if d] injury_dates = [d for d in active_injuries.mapped("injury_date") if d]
patient.injured_since = min(injury_dates) if injury_dates else False patient.injured_since = min(injury_dates) if injury_dates else False
else: else:
patient.is_injured = False patient.injured_since = False
else:
patient.injured_since = False patient.injured_since = False
def _compute_treatment_note_count(self): def _compute_treatment_note_count(self):