Sfoglia il codice sorgente

fix: Use flexible date range for planning slots to capture cross-month slots

- Changed date range filter from strict to flexible boundaries
- Now captures slots that start before or end after the target month
- This should fix issue where Areli Romo shows only 25 hours instead of 99:33
- Uses relativedelta to extend range by 1 day on each side
- Ensures all slots that overlap with the month are included
root 5 mesi fa
parent
commit
25ba73a1eb
1 ha cambiato i file con 3 aggiunte e 2 eliminazioni
  1. 3 2
      hr_efficiency/models/hr_efficiency.py

+ 3 - 2
hr_efficiency/models/hr_efficiency.py

@@ -400,10 +400,11 @@ class HrEfficiency(models.Model):
         Calculate planned hours from planning module
         """
         # Get planning slots for the employee in the date range
+        # Use flexible date range to capture slots that cross month boundaries
         planning_slots = self.env['planning.slot'].search([
             ('employee_id', '=', employee.id),
-            ('start_datetime', '>=', datetime.combine(start_date, datetime.min.time())),
-            ('end_datetime', '<=', datetime.combine(end_date, datetime.max.time())),
+            ('start_datetime', '<', datetime.combine(end_date + relativedelta(days=1), datetime.min.time())),
+            ('end_datetime', '>', datetime.combine(start_date - relativedelta(days=1), datetime.max.time())),
             # Removed state restriction to include all planning slots regardless of state
         ])