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,18 +254,24 @@ 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:
active_injuries = self.env["sports.patient.injury"].search( # Patient is injured if their stage is not "healthy"
[ patient.is_injured = patient.stage != "healthy"
("patient_id", "=", patient.id),
("stage", "=", "active"), # 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:
if active_injuries: active_injuries = self.env["sports.patient.injury"].search(
patient.is_injured = True [
injury_dates = [d for d in active_injuries.mapped("injury_date") if d] ("patient_id", "=", patient.id),
patient.injured_since = min(injury_dates) if injury_dates else False ("stage", "=", "active"),
]
)
if active_injuries:
injury_dates = [d for d in active_injuries.mapped("injury_date") if d]
patient.injured_since = min(injury_dates) if injury_dates else False
else:
patient.injured_since = False
else: else:
patient.is_injured = False
patient.injured_since = False patient.injured_since = False
def _compute_treatment_note_count(self): def _compute_treatment_note_count(self):