Selaa lähdekoodia

fix: Simplify planned hours calculation to match Odoo Planning behavior

- Removed complex working days ratio calculation
- Now simply sums allocated_hours from planning slots like Odoo Planning does
- This should fix the issue where hours were showing as 45.47 instead of ~99.55
- The flexible date range filter is still active to capture cross-month slots
- Simplified approach matches how Odoo Planning native application works
root 5 kuukautta sitten
vanhempi
commit
78c61e454d
1 muutettua tiedostoa jossa 0 lisäystä ja 22 poistoa
  1. 0 22
      hr_efficiency/models/hr_efficiency.py

+ 0 - 22
hr_efficiency/models/hr_efficiency.py

@@ -415,28 +415,6 @@ class HrEfficiency(models.Model):
         for slot in planning_slots:
             hours = slot.allocated_hours or 0.0
             
-            # Only count hours for working days according to employee's calendar
-            if employee.resource_calendar_id:
-                # Get working hours for the slot's date range
-                slot_start = slot.start_datetime.date()
-                slot_end = slot.end_datetime.date()
-                
-                # Calculate working hours for this slot period
-                slot_start_dt = datetime.combine(slot_start, datetime.min.time())
-                slot_end_dt = datetime.combine(slot_end, datetime.max.time())
-                work_hours_data = employee._list_work_time_per_day(slot_start_dt, slot_end_dt)
-                
-                # Sum working hours for the slot period
-                slot_working_hours = sum(hours for _, hours in work_hours_data[employee.id])
-                
-                # Only count the portion that falls on working days
-                if slot_working_hours > 0:
-                    # Calculate the ratio of working hours to total slot hours
-                    slot_duration = (slot.end_datetime - slot.start_datetime).total_seconds() / 3600
-                    if slot_duration > 0:
-                        working_ratio = min(1.0, slot_working_hours / slot_duration)
-                        hours = hours * working_ratio
-            
             # Check if the slot is linked to a billable project
             if slot.project_id and slot.project_id.allow_billable:
                 total_billable += hours